viết chương trình nhập vào 4 số a,b,c,d . Sắp xếp các số đó theo thứ tự giảm dần
1 câu trả lời
uses crt;
Var cs,c,i,j:integer;
a:array[1..4] of integer;
Begin
clrscr;
write('nhap a: ');readln(a[1]);
write('nhap b: ');readln(a[2]);
write('nhapc: ');readln(a[3]);
write('nhap d: ');readln(a[4]);
for i:=1 to 3 do
Begin
Cs:=i;
For j:=i+1 to 4 do if a[j]>=a[cs] then cs:=j;
c:=a[cs];
A[cs]:=a[i];
A[i]:=c;
End;
for i:=1 to 4 do write(a[i],' ');
Readln;
End.