Những câu hỏi liên quan
namok123
Xem chi tiết
Thuy Bui
20 tháng 2 2022 lúc 17:02

tham khảo

 

#include <bits/stdc++.h>

using namespace std;

long long n,i,nn,t1,t2,dem1,dem2,a[1000];

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn<<endl;

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

if (a[i]%2==0) cout<<a[i]<<" ";

cout<<endl;

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

if (a[i]%2!=0) cout<<a[i]<<" ";

cout<<endl;

t1=0;

t2=0;

dem1=0;

dem2=0;

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

{

if (a[i]%2==0)

{

t1+=a[i];

dem1++;

}

else 

{

t2+=a[i];

dem2++;

}

}

cout<<t1<<" "<<dem1<<endl;

cout<<t2<<" "<<dem2;

return 0;

}

Bình luận (0)
Nguyễn Lê Phước Thịnh
20 tháng 2 2022 lúc 22:56

uses crt;

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

i,n,min,t1,t2,dem1,dem2:integer;

begin

clrscr;

readln(n);

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

min:=a[1];

for i:=1 to n do if min>a[i] then min:=a[i];

writeln(min);

writeln('Cac so chan la: ');

for i:=1 to n do 

if a[i] mod 2=0 then write(a[i]:4);

writeln;

writeln('Cac so le la: ');

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

writeln;

t1:=0;

t2:=0;

for i:=1 to n do 

begin

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

else t2:=t2+a[i];

end;

writeln(t1,' ',t2);

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then dem1:=dem1+1

else dem2:=dem2+1;

end;

writeln(dem1,' ',dem2);

readln;

end.

Bình luận (0)
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. 

Bình luận (0)
nông thị ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 3 2021 lúc 19:41

uses crt;

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

n,i,k,t,t1:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

write('Nhap k='); readln(k);

t:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then t:=t+a[i];

t1:=0;

for i:=1 to n do 

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

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

writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);

readln;

end.

Bình luận (1)
Nguyên Đăng
Xem chi tiết
Danh Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 7:23

Bài 1:

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

if ((x<0) and (x%2!=0)) t=t+x;

}

cout<<t;

return 0;

}

Bình luận (0)
ngomanhcuong
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:25

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t,dem;

int main()

{

cin>>n;

dem=0;

t=0;

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

{

cin>>x;

if (x%2==0 && x>10) t+=x;

if (x%2!=0 || x<100) dem++;

}

cout<<t<<" "<<dem;

return 0;

}

Bình luận (0)
Mai Phương Lê
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

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ình luận (0)
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

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.

Bình luận (0)
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

Bài 3: 

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.

Bình luận (0)
an1114
Xem chi tiết
Nguyễn Cảnh Hùng
Xem chi tiết
Đỗ Ngọc Trinh
29 tháng 5 2018 lúc 13:16

Program bt_3;

Uses crt;

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

Dem, Tong, n, i: integer;

Begin

Clrscr;

 Writeln(‘nhap so phan tu, n=’);

 Readln (n);

 for i := 1 to n do

 begin

 writeln(‘nhap gia trij phan tu thu ’,i,’ =’);

 readln(a[i]);

 end;

 Dem:=0;

 Tong:=0;

 For i:=1 to n do

 If (a[i] mod 2 = 1) and (a[i] mod 5 = 0) then

 begin

 Dem:= Dem+1;

 Tong:= Tong+a[i];

 end;

 writeln(‘Dem la:’,Dem);

 Writeln(‘Tong la:’,Tong);

 Readln

End.

Bình luận (0)