求助 if语句完善程序 if…then…else…

任意输入三个整数,比较后,输出最小数

Var a,b,c:integer;
Begin
Read(a,b,c);
PASCAL 语句,麻烦了

第1个回答  2009-06-17
你用的是delphi?
在uses添加 math
Var a,b,c,d:integer;
if min(a,b)=min(a,c) then
d:=min(a,b) else
if min(b,a)=min(b,c) then
d:=min(b,a) else
if min(c,a)=min(c,b) then
d:=min(c,a);
showmessage(inttostr(d));
这样A,B,C三个无论你定义什么数。最后输出的D都是最小的那个数。。

反之 如果你要输出最大数。,把上面代码里的min改成max。。
第2个回答  2009-06-18
var
A,B,C,min:longint;
begin
Read(a,b,c);
if ((a<b) and (b<c)) or ((a<c) and (c<b)) then min:=a
else if ((b<a) and (a<c)) or ((b<c) and (c<a)) then min:=b
else if ((c<a) and (a<b)) or ((c<b) and (b<a)) then min:=c;
writeln(min);
end.

经过调试,没有发现问题!希望对你有帮助。。
第3个回答  2009-06-17
不知道你的是什么遗言编写的这是我找到的十个数字输出最小的,你参考下吧。。。
procedure Bubble_Sort(var L:List);
var
i,j:position;
begin
1for i:=First(L) to Last(L)-1 do
2 for j:=First(L) to Last(L)-i do
3 if L[j]>L[j+1] then
4 swap(L[j],L[j+1]); //交换L[j]和L[j+1]
end;
第4个回答  2009-06-18
program work;
var
a,b,c:integer;
min:integer;
begin
realn(a,b,c)
if a<b then if b<c then min:=a
else if c<a then min:=c
else min:=a
else if a<c then min:=b
else if c<b then min:=c
else min:=b;
writeln(min);
end.
第5个回答  2009-06-17
var d:integer
if a>b then
d=b;
else
d=a;
if d>c then
d=c;

write(d);本回答被提问者采纳

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网