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.
program (Nhập tên gì ở dây cx đc tùy bạn);;
ues crt;
var A:array [1..1000] of integer;
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.
b)
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.
Program Day_So_Giam_Dan;
Uses Crt;
Var s,n,i,j,t:integer;
a:array[1..20] of integer;
Begin
Clrscr;
Writeln(‘SAP XEP DAY SO:’);
Write(‘Nhap so phan tu cua day 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
t:=a[i];
a[i]:=a[j];
a[j]:=t;
End;
Writeln(' Day sau khi sap xep giam dan la:'); For i:=1 to n do
Write(a[i]:4); Readln;
s:=0;
For i:=1 to n do s:=s+a[i];
Writeln('Gia tri trung binh la: ',s/n:6:2);
Readln;
End.
#include <bits/stdc++.h>
using namespace std;
int A[1000],n,i;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
sort(A+1,A+n+1);
for (int i=1; i<=n; i++)
cout<<A[i]<<" ";
cout<<endl;
for (int i=2; i<=n; i++)
cout<<A[i]-A[i-1]<<endl;
return 0;
}
Uses crt;
Var k: array[1..10] of integer;
i,j,n: byte;
t: integer;
begin clrscr;
Readln(n);
For i:=1 to n do Begin
readln(k[i]);
end;
For i:=1 to n-1 do For j:=i+1 to n do
if k[j] <=k[i] then begin
t:= k[i];
k[i]:=M[j];
k[j]:=t; end;
For i:=1 to n do Write(k[i],';'); readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<max(a,b)<<" "<<min(a,b);
return 0;
}
Program Tin_hoc;
Uses crt;
Var i,tam,n,chan,le,j:integer;
a,daychan,dayle:array[1..10000] of integer;
Begin
clrscr;
Write('Nhap n: ');readln(n);
chan:=0;le:=0;
Writeln('Nhap ',n,' phan tu cua mang:');
For i:= 1 to n do
Begin
write('A[',i,'] = ');
Readln(a[i]);
If a[i] mod 2 = 0 then
Begin
inc(chan);
daychan[chan]:=a[i];
end
else
Begin
inc(le);
dayle[le]:=a[i];
End;
End;
For i:= 1 to chan do
for j:= i to chan do If daychan[i]>daychan[j] then
Begin
tam:=daychan[i];
daychan[i]:=daychan[j];
daychan[j]:=tam;
End;
For i:= 1 to le do
for j:= i to le do If dayle[i]<dayle[j] then
Begin
tam:=dayle[i];
dayle[i]:=dayle[j];
dayle[j]:=tam
End;
Writeln('Day sau khi sap xep:');
For i:= 1 to chan do write(daychan[i],' ');
For i:= 1 to le do write(dayle[i],' ');
Readln;
End.
Program tangdan;
Uses crt;
Var n,i,j,k,t:interger;
A: array[1..100] of longint;
Begin
Clrscr;
Write('Nhap do dai day: '); 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
t:=A[i];
A[i]:=A[j];
A[j]:=t;
End;
Write('Day sau khi duoc sap xep theo thu tu tang dan la: ',A[i]:3);
End.