Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
1)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] > a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep tang dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
2)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] < a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep giam dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
Câu 1:
Program HOC24;
var a: array[1..1000] of integer;
i,n: integer; tbc: real;
begin
write('Nhap so phan tu trong mang: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
tbc:=0;
for i:=1 to n do tbc:=tbc+a[i];
tbc:=tbc/n;
write('Trung binh cong la: ',tbc:6:2);
readln
end.
Câu 2:
Program HOC24;
var a: array[1..1000] of integer;
i,n,h,tg: integer;
begin
write('Nhap so phan tu trong mang: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
for i:=1 to n do
for j:=i to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
write('Mang sau khi sap xep la: ');
for i:=1 to n do write(a[i].' ');
readln
end.
Program hotrotinhoc;
var a,b: array[1..6] of integer;
i,j,tg: integer;
begin
a[1]:=3; a[2]:=1; a[3]:=7; a[4]:=9; a[5]:=5;
b[1]:=10; b[2]:=2; b[3]:=8; b[4]:=9; b[5]:=6; b[6]:=5;
for i:=1 to 5 do
for j:=i to 5 do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
write('Day 1 sau khi doi cho la : ');
for i:=1 to 5 do write(a[i],' ');
writeln;
write('Day 2 sau khi doi cho la : ');
for i:=1 to 6 do
for j:=i to 6 do
if b[i]<b[j] then
begin
tg:=b[i];
b[i]:=b[j];
b[j]:=tg;
end;
for i:=1 to n do write(b[i],' ');
readln
end.