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.
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.
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.
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.
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.
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.
uses crt;
var n,i,s,t,j,max:longint;a,b:array[1..100] of longint;tbc:real;
function snt(n:longint):boolean;
var j:longint;
begin
for j:=2 to trunc(sqrt(n)) do
if n mod j=0 then exit(false);
exit(n>1);
end;
begin
readln(N);
for i:=1 to n do
begin
read (a[i]);
if snt(a[i])=true then
begin
j:=j+1;
b[j]:=a[i];
end;
end;
t:=b[1];
max:=b[1];
for i:=2 to j do
begin
if b[i]>max then max:=b[i];
t:=t+b[i];
write(b[i]:4);
end;
tbc:=t/j;
writeln(S);
writeln(tbc);
writeln(max);
readln;
end.
Giúp em với ạ -.-