f.4 pascal programming

2007-02-20 10:13 pm
有個programme既output系咁:
----------------------------------------------------------
enter #s (0 to stop):
17.7
2.8
9.6
0

Largest = 17.7
Smallest = 2.8
------------------------------------------------------------
我想問呢個largest同smallest果2part應該點寫?

回答 (1)

2007-02-21 12:32 pm
✔ 最佳答案
任何的 Programming 找出 Maxmiun and Minimun 有很多種做法
首先定義兩個 Variable max, min
Repeat Until Loop 是一個 Loop 讓你於未
滿足的條件之下不斷運行

var max : real;
var min : real;
var s : integer;
min = 0;
max = 0;

begin
writeln("enter #s (0 to stop):")

repeart
readln(s);
if max < s then
max = s;
if min > s then
min = s;
until s=0 ;

write("Largest =");
writln(max);
write("Smallest=");
writeln(min);
end.


收錄日期: 2021-04-12 22:51:18
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070220000051KK01643

檢視 Wayback Machine 備份