Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
Đại Hà
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 12 2021 lúc 10:05

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;

}

Trần Văn Việt Hùng
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 3 2022 lúc 20:31

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.

my trần
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 8 2021 lúc 19:15

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. 

quang thanh truong
Xem chi tiết
Minh Lệ
1 tháng 5 2022 lúc 19:08

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.

VŨ MINH HOÀNG
Xem chi tiết
Lô Minh Quân
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 3 2022 lúc 10:25

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;

}

ILoveMath đã xóa
Nguyễn Văn Tú
Xem chi tiết
Nguyễn Quang Hà
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 2 2022 lúc 13:39

#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;

}

Hoàng Vlogs
Xem chi tiết