K
Khách

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.

18 tháng 12 2021

a: 

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,t1,t2;

int main()

{

cin>>n;

t1=0;

t2=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0) t1=t1+x;

else t2=t2+x;

}

cout<<t1<<" "<<t2;

return 0;

}

18 tháng 12 2021

a: #include <bits/stdc++.h>

using namespace std;

unsigned long long int n,i,t1,t2,x;

int main()

{

cin>>n;

t1=0;

t2=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0) t1=t1+x;

else t2=t2+x;

}

cout<<t1<<endl;

cout<<t2;

return 0;

}

uses crt;

var a:array[1..100]of integer;

i,n,t,t1,j,tam:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

t:=0;

for i:=1 to n do t:=t+a[i];

t1:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then t1:=t1+a[i];

for i:=1 to n-1 do 

  for j:=i+1 to n do 

 if a[i]<a[j] then

begin

tam:=a[i];

a[i]:=a[j];

a[j]:=tam;

end;

writeln(t);

writeln(t1);

for i:=1 to n do write(a[i]:4);

readln;

end.

uses crt;

var a:array[1..100]of integer;

i,n,dem,max,t,min,dem1:integer;

begin

clrscr;

write('n='); readln(n);

for i:=1 to n do 

 begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

max:=-32000;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then 

begin

dem:=dem+1;

if max<a[i] then max:=a[i];

end;

if dem=0 then writeln('Trong day khong co so chan')

else begin

writeln('So so chan la: ',dem);

writeln('So chan lon nhat la: ',max);

end;

t:=0;

for i:=1 to n do 

  if i mod 2=1 then t:=t+a[i];

writeln('Tong cac so o vi tri le la: ',t);

min:=maxint;

dem1:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then

begin  

inc(dem1);

if min>a[i] then min:=a[i];

end;

if dem1=0 then writeln('Trong day khong co so le')

else writeln('So le nho nhat la: ',min);

readln;

end. 

1 tháng 5 2022

Program HOC24;

var min,max,n,i: integer;

t: longint;

a: array[1..1000] of integer;

begin

write('Nhap N: '); readln(n);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

write('Cac so chan trong mang la: ');

for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ');

writeln;

t:=0;

for i:=1 to n do if a[i] mod 2=1 then t:=t+a[i];

writeln('Tong cac so le la: ',t);

min:=a[1]; max:=a[1];

for i:=1 to n do

begin

if a[i]>max then max:=a[i];

if a[i] <max then max:=a[i];

end;

writeln('Gia tri lon nhat la: ',max);

write('Gia tri nho nhat la:' ,min);

readln

end.

1 tháng 5 2022

cô tách câu a,b ,c ra dc không cô

Câu 4: 

#include <bits/stdc++.h>

using namespace std;

string st;

int d,i,dem;

char x;

int main()

{

getline(cin,st);

d=st.length();

cout<<st<<endl;

cin>>x;

dem=0;

for (i=0; i<=d-1; i++) if (st[i]==x) dem++;

cout<<dem;

return 0;

}

Câu 4: 

#include <bits/stdc++.h>

using namespace std;

string st;

int d,i,dem;

char x;

int main()

{

getline(cin,st);

d=st.length();

cout<<st<<endl;

cin>>x;

dem=0;

for (i=0; i<=d-1; i++) if (st[i]==x) dem++;

cout<<dem;

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;

}