Tin học Chương trình nhập n số thực từ bàn phím sau đó sắp xếp và in ra màn hình dãy số đó theo thứ tự không giảm n được nhập từ bàn phím 17/07/2021 By Sarah Chương trình nhập n số thực từ bàn phím sau đó sắp xếp và in ra màn hình dãy số đó theo thứ tự không giảm n được nhập từ bàn phím
ues crt;var a:array [1..100] of real; i,j,n,tg:integer;begin clrscr; write(‘Nhap so phan tu n: ‘); readln(n); for i:=1 to n do begin writeln(‘Nhap so thu ‘,i,’: ‘); readln(A[i]); end; for i:=1 to n-1 do for j:=i+1 to n do if A[i]>A[j] then begin tg:=A[i]; A[i]:=A[j]; A[j]:=tg; end; writeln(‘Day so sap xep theo thu tu tang dan la: ‘); for i:=1 to n do write(A[i]:3);readln;end. Trả lời
program phuongt;uses crt; var A: array[1..500] of integer; n, t, j, i: integer;begin clrscr; write(‘Nhap n = ‘); readln(n); s:=0; for i:=1 to n do begin write(‘A[‘, i, ‘] = ‘); readln(A[i]); end; for i:=1 to n-1 do for j:=1+i to n do if A[i]>A[j] then begin t:=A[i]; A[i]:=A[j]; A[j]:=t; end; write(‘Sap xep: ‘); for i:=1 to n do write(A[i]:3); readlnend. Trả lời