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.
tham khảo'
uses crt;
var a:array[1..100]of integer;
i,n,t,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chan la: ',t);
writeln('So luong so chan la: ',dem);
readln;
end.
Var a:array[1..100] of integer;
i,n,dem,vt,s sc,sl,min:integer;
tbc:real;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do s:=s+a[i];
tbc:=s/n;
Writeln('Gia tri trung binh cua mang la ',tbc:10:2);
Write('Cac phan tu lon hon gia tri trung binh la ');
For i:=1 to n do
If a[i]>tbc then write(a[i],' ');
For i:=1 to n do
Begin
If a[i] mod 2 = 0 then sc:=sc+a[i]
Else sl:=sl+a[i];
End;
Writeln('Tong cac phan tu chan la ',sc);
Writeln('Tong cac phan tu le la ',sl);
min:=a[1];
For i:=2 to n do
Begin
If a[i] < min then min:=a[i];
vt:=i;
End;
Writeln('Phan tu nho nhat la ',min,' tai vi tri ',vt);
For i:=1 to n do
If a[i] mod 5 = 0 then dem:=dem+1;
Write('So cac phan tu chia het cho 5 la ',dem);
Readln;
End.
var a:array[1..100] of integer;
i,n,S,d:byte;
begin
write(' n = '); readln(n);
for i:=1 to n do begin
write('A[',i,'] = ');
readln(A[i]);
end;
d:=0; S:=0;
for i:=1 to n do if A[i] mod 2 = 0 then begin
d:=d+1;
S:=S+A[i];
end;
write('Dãy có ',d,' phần tử là số chẵn và tổng của chúng là : S = ',S);
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long a[150],i,s,n,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
s=1;
for (i=1; i<=n; i++)
if (a[i] %2!=0 && a[i]%3==0) s=s*a[i];
cout<<s<<endl;
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
for (i=n; i>=1; i--)
if (nn==a[i])
{
cout<<i<<endl;
break;
}
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
uses crt;
var C : array [1 .. 50] of integer;
i, n : integer;
begin
clrscr;
write('Nhap so phan tu : '); readln(n);
write('Nhap day gom ', n ,' so : ');
for i := 1 to n do read(C[i]);
write('Cac gia tri chan : ');
for i := 1 to n do
if C[i] mod 2 = 0 then write(C[i], ' ');
readln
end.
#include <bits/stdc++.h>
using namespace std;
int A[500],n,i,dem,dem1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
for (int i=n; i>=1; i--) cout<<A[i]<<" ";
cout<<endl;
dem=0;
for (int i=1; i<=n; i++)
if (A[i]<10) dem++;
cout<<dem<<endl;
dem1=0;
for (int i=1; i<=n; i++)
if (A[i]>1)
{
bool kt=true;
for (int j=2; j*j<=A[i]; j++)
if (A[i]%j==0) kt=false;
if (kt==true) dem1++;
}
cout<<dem1;
return 0;
}
uses crt;
var b,a:array[1..100]of integer;
i,n,dem,dem1,dem2,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if b[i]<0 then inc(dem);
if b[i]>0 then inc(dem1);
end;
writeln('So phan tu am la: ',dem);
writeln('So phan tu duong la: ',dem1);
t:=0;
for i:=1 to n do
if b[i]<>0 then t:=t+b[i];
writeln('Trung binh cac phan tu khac 0 trong mang la: ',t/(dem+dem1):4:2);
min:=b[1];
for i:=1 to n do
if min>b[i] then min:=b[i];
dem2:=0;
for i:=1 to n do
if min=b[i] then
begin
inc(dem2);
a[dem2]:=i;
end;
writeln('Gia tri nho nhat la: ',min);
writeln('Chi so la: ');
for i:=1 to dem2 do
write(a[i]:4);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,t,t1,dem,dem1;
//chuongtrinhcon
bool ktnt(long long x)
{
if (x<=1) return(false);
for (int i=2; i*i<=x; i++)
if (x%i==0) return(false);
return true;
}
//chuongtrinhchinh
int main()
{
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];
cout<<t<<endl;
dem=0;
for (i=1; i<=n; i++) if (a[i]%3==0) dem++;
cout<<dem<<" ";
t1=0;
dem1=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0)
{
t1+=a[i];
dem1++;
}
cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;
for (i=1; i<=n; i++)
if (ktnt(a[i])==true) cout<<a[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,nn,t;
int main()
{
cin>>n;
nn=LLONG_MAX;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
t+=x;
nn=min(nn,x);
}
cout<<nn<<" "<<t;
return 0;
}