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.
1:
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
t=t+x;
}
cout<<t;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem,dem1,dem2,t:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]>10 then inc(dem);
writeln('So phan tu lon hon 10 la: ',dem);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
writeln('So luong so chan la: ',dem1);
writeln('So luong so le la: ',dem2);
t:=0;
s:=1;
for i:=1 to n do
begin
if (i mod 2=0) and (a[i] mod 2<>1) then t:=t+a[i];
if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];
end;
writeln('Tong cac so o vi tri chan co gia tri le la: ',t);
writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);
writeln('Cac so le la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
writeln('Cac so chan va lon hon 10 la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>10) then write(a[i]:4);
readln;
end.
uses crt;
var a,vtmax,vtmin:array[1..100]of integer;
n,i,max,min,dem,t,dem1,t1,dem2,t2,dem3,t3,dem4,t4,k:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('So lon nhat trong day la: ',max);
dem:=0;
t:=0;
for i:=1 to n do
if max=a[i] then
begin
inc(dem);
t:=t+a[i];
vtmax[dem]:=i;
end;
if dem>1 then
begin
writeln('Tong cac so max la: ',t);
writeln('Cac vi tri co so max la: ');
for i:=1 to dem do
write(vtmax[i]:4);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln('So nho nhat trong day la: ',min);
dem1:=0;
t1:=0;
for i:=1 to n do
if min=a[i] then
begin
inc(dem1);
t1:=t1+a[i];
vtmin[dem1]:=i;
end;
if dem1>1 then
begin
writeln('Tong cac so min la: ',t1);
writeln('Cac vi tri co so min la: ');
for i:=1 to dem1 do
write(vtmin[i]:4);
end;
write('Nhap k='); readln(k);
dem2:=0;
t2:=0;
for i:=1 to n do
if (i mod 2=0) and (a[i] mod k=0) then
begin
dem2:=dem2+1;
t2:=t2+a[i];
end;
writeln('So phan tu o vi tri chan trong day la boi cua ',k,' la: ',dem2);
writeln('Tong cac so o vi tri chan trong day la boi cua ',k,' la: ',t2);
dem3:=0;
t3:=0;
for i:=1 to n do
if (i mod 2=1) and (k mod a[i]=0) then
begin
inc(dem3);
t3:=t3+a[i];
end;
writeln('So phan tu o vi tri le trong day la uoc cua ',k,' la: ',dem3);
writeln('Tong cac so o vi tri le trong day la uoc cua ',k,' la: ',t3);
dem4:=0;
t4:=0;
for i:=1 to n do
if (a[i]+k=1) or (a[i]=k+1) then
begin
inc(dem4);
t4:=t4+a[i];
end;
writeln('So phan tu la anh em cua ',k,' trong day la: ',dem4);
writeln('Tong cac phan tu la anh em cua ',k,' trong day la: ',t4);
readln;
end.
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;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
dem:=0;
for i:=1 to n do
if a[i] mod 2=1 then inc(dem);
writeln('Tong cac so chan la: ',t);
writeln('So luong so duong le la: ',dem);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chan la: ');
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i]:4);
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chan la: ',t);
writeln('Trong day co ',dem,' so chan');
readln;
end.
uses crt;
var a:array[1..250]of integer;
i,n,dem,t,t1,t2,t3,t4:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=250);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until (0<a[i]) and (a[i]<=500);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 2=1 then inc(dem);
writeln('So phan tu co gia tri le la: ',dem);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu co chi so chan la: ',t);
t1:=0;
for i:=1 to n do
if i mod 2=1 then t1:=t1+a[i];
writeln('Tong cac phan tu co chi so le la: ',t1);
t2:=0;
for i:=1 to n do
if (i mod 2=0) and (a[i] mod 2=0) then t2:=t2+a[i];
writeln('Tong cac phan tu chan co chi so chan la: ',t2);
t3:=0;
for i:=1 to n do
if (i mod 2=1) and (a[i] mod 2=1) then t3:=t3+a[i];
writeln('Tong cac phan tu co chi so le la: ',t3);
t4:=0;
for i:=1 to n do
t4:=t4+a[i];
writeln('Trung binh cong cac so trong day la: ',t4/n:4:2);
readln;
end.
Var so,n,i:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(so);
If (so mod 3 = 0) and (so mod 5 = 0) then
s:=s+so;
End;
Write('Tong la ',s);
Readln;
End.
uses crt;
var a:array[1..100]of integer;
i,n,tc,tl,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
tc:=0;
tl:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then tc:=tc+a[i]
else tl:=tl+a[i];
end;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
readln;
end.
1:
#include <bits/stdc++.h>
using namespace std;
long long n,i,dem,x;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x==0) dem++;
}
cout<<dem;
return 0;
}