回 帖 发 新 帖 刷新版面

主题:发个简单的题目,答对++++++分

输入3个数,按由大到小顺序打印出来。

回复列表 (共10个回复)

沙发

没人会吗????????

板凳

var
a,b,c,t:integer;

begin
if a<b then t:=a; a:=b; b:=t else if a<c then t:=a; a:=c; c:=t else if b<c then t:=b; b:=c; c:=t;
readln(a:8,b:8,c:8);
end.

3 楼

var
a:array[1..3] of integer;
s,t,x,k,i,j:integer;
procedure quicksort(s,t:integer);
begin
i:=s;j:=t;x:=a[s];
while i<j do
begin
while (a[j]>=x) and (i<j) do
j:=j-1;
if (i<j) then
begin
a[i]:=a[j];
i:=i+1;
end;
while (a[i]<=x) and (i<j) do
i:=i+1;
if (i<j) then
begin
a[j]:=a[i];
j:=j-1;
end;
a[i]:=x;
end;
if s<(i-1) then quicksort(s,i-1);
if (i+1)<t then quicksort(i+1,t);
end;
begin
for i:=1 to 3 do
readln(a[i]);
quicksort(1,3);
for i:=1 to 3 do
write(a[i],' ');
readln;
end.

4 楼

呀!!!二楼的错程序也能拿三十分呀???
不就是三个数比较大小吗,三楼的程序至于定义这么多变量吗!!!
还用数组,过程之类的.需要吗???重要的是写出的程序是个错的耶!!!
程序不是越复杂越好,而是越简单越好呀................................

5 楼

program zhs (input,output);
  var
    x,y,z,temp:real;
  begin
    read(x,y,z);
    if x<y
      then begin
             temp:=x;
             x:=y;
             y:=temp
           end;
    if y<z
      then begin
             temp:=y;
             y:=z;
             z:=temp
           end;
    if x<y
      then begin
             temp:=x;
             x:=y;
             y:=temp
           end;
    writeln(x:10,y:10,z:10)
  end.

6 楼

var
a,b,c,t:longint;
begin
readln(a,b,c);
if b>a then begin
              t:=a;
              a:=b;
              b:=t;
             end;
if c>a then begin
              t:=a;
              a:=c;
              c:=t;
             end;
if c<b then begin
              t:=b;
              b:=c;
              c:=t;
             end;
writeln(a:10,b:10,c:10);
end.

7 楼

-_-!,其实没有这么复杂,4个IF就足够了

8 楼

n>16时,三楼的最简单(在计算机看来)

9 楼

program myList (input,output);
  var
    x,y,z:real;
  function myMax(var a,b:real)
   var t:real;
   begin
      if a<b then
          t:=b;
          b:=a;
          a:=t;
    end
  begin
    read(x,y,z);
    myMax(x,y);
    myMax(y,z);
    myMax(x,y);
    writeln(x:10,y:10,z:10);
  end.


我是新手,不知做的对不对,我没调试过.

10 楼

program lv;
var
k,a,b,c:integer;
begin
readln(a,b,c);
for k:=1 to 65535 do
begin
if a=k then write(a);
if b=k then write(b);
if c=k then write(c);
end;
end.

我来回复

您尚未登录,请登录后再回复。点此登录或注册