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.
Var a:array[1..1000] of integer;
i,m,tam:integer;
Begin
Write('m = ');readln(m);
For i:=1 to m do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to m do
If a[i] < a[i+1] then
Begin
tam:=a[i];
a[i]:=a[i+1];
a[i+1]:=tam;
End;
Write('Mang sau khi sap xep: ');
For i:=1 to m do
Write(a[i]:8);
Readln;
End.
uses crt;
var a:array[1..100]of integer;
i,n,min,tam,j:integer;
begin
clrscr;
n:=100;
for i:=1 to 100 do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln('Gia tri nho nhat la: ',min);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('Day so tang dan la: ');
for i:=1 to n do
write(a[i]:4);
readln;
end.
tham khảo:
uses crt;
var n,i:integer;
a:array[1..100] of integer;
begin
clrscr;
write(‘nhap so phan tu cua day:’);readln(n);
for i:=1 to n do
begin
write(‘a[‘,i,’]=’);readln(a[i]);
end;
writeln(‘day so da nhap:’);
for i:=1 to n do write(a[i]:2);
readln;
end.
Bạn thử xem cách mình làm đc ko?
___________
uses crt;
var A:array[1..1000] of integer;
n,i,tc,tl,z,j,e,tic,til,dem,d,dc,dl:integer;
begin
clrscr;
Write('Nhap n: '); readln(n);
for i:=1 to n do
begin
Write('Nhap phan tu thu ',i,' :'); readln(A[i]);
end;
i:=1;
tc:=0;
tl:=0;
for d:=1 to n do if (A[d] mod 2=0) then dc:=dc+1 else dl:=dl+1;
if (dc<>0) then tic:=1 else tic:=0;
if (dl<>0) then til:=1 else til:=0;
for i:=1 to n do if (A[i] mod 2=0) then
begin
tc:=tc+A[i];
tic:=tic*A[i];
end
else
begin
tl:=tl+A[i];
til:=til*A[i];
end;
Writeln('Tong cac phan tu chan la: ' ,tc);
Writeln('Tich cac phan tu chan la: ' ,tic);
Writeln('Tong cac phan tu le la: ' ,tl);
Writeln('Tich cac phan tu le la: ' ,til);
for e:=1 to (n-1) do
for j:=e+1 to n do
if A[e]>A[j] Then
begin
z:=A[e]; A[e]:=A[j]; A[j]:=z;
end;
Writeln('Day sau khi duoc sap xep tang dan la: ');
for dem:=1 to n do Write(A[dem],' '); writeln;
writeln('Day sau khi duoc sap xep giam dan la: ');
for dem:=n downto 1 do write(A[dem],' ');
readln;
end.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,tam,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',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
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
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.