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;
int main()
{
int n,A[100],dem,t;
cin>>n;
for (int i=1; i<=n; i++)
cin>>A[i];
dem=0; t=0;
for (int i=1; i<=n; i++)
if (A[i]%2==0) dem++;
else t+=A[i];
cout<<dem<<endl;
cout<<t;
return 0;
}
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
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 do
if a[i] mod 2<>0 then write(a[i]:4);
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
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 do
if a[i] mod 2=0 then write(a[i]:4);
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] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
uses crt;
var a:array[1..4]of integer;
i,t:integer;
begin
clrscr;
for i:=1 to 4 do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to 4 do
if a[i] mod 2<>0 then t:=t+a[i];
writeln(t);
readln;
end.
uses crt;
var n,i,t1,t2:integer;
begin
clrscr;
t1:=0;
t2:=0;
repeat
readln(n);
if n mod 2=0 then t1:=t1+n
else t2:=t2+n;
until n=0;
writeln(t1,' ',t2);
readln;
end.
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.