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[200],n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
const fi='input.txt';
fo='output.txt';
var f1,f2:text;
a:array[1..100]of integer;
i,n,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
inc(n);
read(f1,a[n]);
end;
t:=0;
for i:=1 to n do t:=t+a[i];
write(f2,t);
close(f1);
close(f2);
end.
#include <bits/stdc++.h>
using namespace std;
double a[100];
int i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
for (i=1; i<=n; i++)
swap(a[i],a[n+1-i]);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
bn ơi bn làm bằng pascal đc ko ạ, mik cần cả hai cái lun
uses crt;
var a:array[1..100]of integer;
i,n,tam,j:integer;
{---------------chuong-trinh-con----------------------}
procedure hoandoi(x,y:integer);
var tam:integer;
begin
tam:=x;
x:=y;
y:=tam;
end;
{--------------------chuong-trinh-chinh---------------------------}
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
hoandoi(a[i],a[j]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
var A:
array[1..n] of integer;
i, j, n: integer;
begin
write('Nhap so phan tu cua 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 - 1 do
for j := i+1 to n do
if (A[i] mod 2 = 0) and (A[j] mod 2 = 0) and (A[i] < A[j]) or (A[i] mod 2 = 1) and (A[j] mod 2 = 1) and (A[i] > A[j]) then
begin
swap(A[i], A[j]);
end;
writeln('Mang da sap xep la: ');
for i := 1 to n do
writeln(A[i]);
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,chon;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
cin>>chon;
if (chon==0)
{
for (i=1; i<=n; i++) cout<<a[i]<<" ";
}
else
{
for (i=n; i>=1; i--) cout<<a[i]<<" ";
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
t=0;
for (i=1; i<=n; i++) t+=a[i];
cout<<t<<endl;
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[1000];
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}