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.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
for (i=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}
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.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
for (i=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}
program SapXepMang;
var
N, i, j, temp: integer;
arr: array of integer;
begin
write('Nhap N: ');
readln(N);
SetLength(arr, N);
for i := 0 to N - 1 do
begin
write('Nhap phan tu thu ', i + 1, ': ');
readln(arr[i]);
end;
for i := 0 to N - 2 do
for j := i + 1 to N - 1 do
if arr[i] < arr[j] then
begin
temp := arr[i];
arr[i] := arr[j];
arr[j] := temp;
end;
writeln('Mang da sap xep theo thu tu giam dan: ');
for i := 0 to N - 1 do
write(arr[i], ' ');
readln;
end.
uses crt;
var a:array[1..5] of integer;
i, j, t, dem : integer;
begin
clrscr;
writeln('nhap mang gom 5 so :');
for i:=1 to 5 do
begin
write('a[',i,']=');readln(a[i]);
end;
writeln('mang vua nhap la:');
for i:=1 to 5 do write(a[i]:3);
writeln;
dem:=0;
for i:=1 to 5 do
if a[i] mod 2 <>0 then
begin
dem:=dem+1;
writeln(a[i],' la phan tu le');
end;
if dem=0 then writeln('trong mang khong co phan tu le');
for i:=1 to 4 do
for j:=i+1 to 5 do
if a[i]>a[j] then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
end;
writeln('mang da duoc sap xep theo chieu tang dan la:');
for i:=1 to 5 do write(a[i]:3);
readln;
end.
uses crt;
var a,b,c:array[1..100]of longint;
n,m,i,j,dem,tam:integer;
begin
clrscr;
{------------nhap-mang-A----------------}
write('chieu dai mang A='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{------------nhap-mang-B----------------}
write('chieu dai mang B='); readln(m);
for j:=1 to m do
begin
write('b[',j,']='); readln(b[j]);
end;
{-----------------xuat-day-A--------------------}
writeln('day A=');
for i:=1 to n do
write(a[i]:4);
{---------------xuat-day-B--------------------}
writeln;
writeln('day B=');
for j:=1 to m do
write(b[j]:4);
writeln;
{------------sap-xep-mang-A------------------}
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 A sau khi sap xep la: ');
for i:=1 to n do write(a[i]:4);
{-----------sap-xep-mang-B------------------}
writeln;
for i:=1 to m-1 do
for j:=i+1 to m do
if b[i]>b[j] then
begin
tam:=b[i];
b[i]:=b[j];
b[j]:=tam;
end;
writeln('day B sau khi sap xep la: ');
for j:=1 to m do write(b[j]:4);
{--------------cho-cac-phan-tu-cua-A-va-B-vao-array-C------------------}
writeln;
writeln('day C=');
dem:=0;
for i:=1 to n do
begin
inc(dem);
c[dem]:=a[i];
end;
for j:=1 to m do
begin
inc(dem);
c[dem]:=b[j];
end;
for i:=1 to dem do write(c[i]:4);
{----------------sap-xep-mang-C-----------------}
for i:=1 to dem-1 do
for j:=i+1 to dem do
if c[i]>c[j] then
begin
tam:=c[i];
c[i]:=c[j];
c[j]:=tam;
end;
writeln;
writeln('day C sau khi sap xep la: ');
for i:=1 to dem do
write(c[i]:4);
readln;
end.