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;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
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.