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[10000],i,n,t1,t2,dem1,dem2;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
dem1=0;
dem2=0;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
if (a[i]>0)
{
dem1++;
t1+=a[i];
}
if (a[i]<0)
{
dem2++;
t2+=a[i];
}
}
long long t3=0;
for (i=1; i<=n; i++)
if (i%2==1) t3+=a[i];
long long t4=0;
for (i=1; i<=n; i++)
if (i%2==1 && a[i]%2==0) t4+=a[i];
cout<<t1<<" "<<t2<<endl;
cout<<dem1<<" "<<dem2<<endl;
cout<<t3<<endl;
cout<<t4<<endl;
for (i=1; i<=n; i++)
if (a[i]%3==0) cout<<a[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t1,t2,t3;
int main()
{
cin>>n;
t1=0; t2=0; t3=0;
for (i=1; i<=n; i++)
{
cin>>x;
t1+=x;
if (x%2==0) t2+=x;
else t3+=x;
}
cout<<t1<<" "<<t2<<" "<<t3;
return 0;
}
uses crt;
var a,b,c,d,tl,tc:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
write('Nhap d='); readln(d);
tc:=0;
tl:=0;
if a mod 2=0 then tc:=tc+a
else tl:=tl+a;
if b mod 2=0 then tc:=tc+b
else tl:=tl+b;
if c mod 2=0 then tc:=tc+c
else tl:=tl+c;
if d mod 2=0 then tc:=tc+d
else tl:=tl+d;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t: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]<0) and (i mod 2=1) then t:=t+a[i];
writeln('Tong cac phan tu am tai vi tri le la: ',t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
for i:=1 to n do
if i mod 2=1 then write(a[i]:4);
readln;
end.