Những câu hỏi liên quan
DƯƠNG VĂN TÀI
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 10 2021 lúc 15:16

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,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)
Thanh Nhi Phạm
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 4 2021 lúc 20:12

Mình chỉ viết chương trình chính thôi, còn chương trình con bạn tự viết nhé

uses crt;

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

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

begin

clrscr;

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

for i:=1 to n do 

 begin

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

edn;

t:=0;

for i:=1 to n do 

 t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
Nguyễn Anh Quân
Xem chi tiết
sang nguyen van
Xem chi tiết
Nguyễn Lê Phước Thịnh
6 tháng 11 2021 lúc 0:19

#include <bits/stdc++.h>

using namespace std;

long long i,n,x,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

if (x>0) t=t+x;

}

cout<<t;

return 0;

}

Bình luận (0)
Lam Nguyễn Xuân
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:03

uses crt;

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

i,n,k,t: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 k=0 then t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
IVR Gaming
15 tháng 10 2021 lúc 10:16

lớp 11 bth học quy hoạc động ??

 

Bình luận (0)
Tiên Nguyễn
Xem chi tiết
Bùi Anh Tuấn
29 tháng 12 2020 lúc 19:51

phần a

Bình luận (1)
Bùi Anh Tuấn
29 tháng 12 2020 lúc 19:52

phần b

Bình luận (0)
Lê Thị Bích Ngân
Xem chi tiết
Thiên Nhật
Xem chi tiết
Vương Hương Giang
14 tháng 2 2022 lúc 14:26

uses crt;

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

i,n,tc,tl,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

tc:=0;

tl:=0;

for i:=1 to n do 

  begin

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

else tl:=tl+a[i];

end;

writeln('Tong cac so chan la: ',tc);

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

t:=0;

for i:=1 to n do  

t:=t+a[i];

writeln('Tong cua day so la: ',t);

readln;

end. 

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

uses crt;

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

i,n,dem1,dem2,t1,dem3,j,kt:integer;

begin

clrscr;

readln(n);

for i:=1 to n do 

  readln(a[i]);

dem1:=0;

dem2:=0;

t1:=0;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then 

begin

dem1:=dem1+1;

t1:=t1+a[i];

end;

else dem2:=dem2+1;

end;

dem3:=0;

for i:=1 to n do 

  if (a[i]>1) then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then dem3:=dem3+1;

end;

writeln(dem1, ' ',dem2);

writeln(t1);

writeln(dem3);

readln;

end.

Bình luận (0)
Sarah Lilia
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2021 lúc 20:53

uses crt;

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

i,n,dem,dem1,dem2,t:integer;

s:real;

begin

clrscr;

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

for i:=1 to n do 

begin

repeat

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

until a[i]>0;

end;

for i:=1 to n do 

  write(a[i]:4);

writeln;

dem:=0;

for i:=1 to n do

  if a[i]>10 then inc(dem);

writeln('So phan tu lon hon 10 la: ',dem);

dem1:=0;

dem2:=0;

for i:=1 to n do 

begin

if a[i] mod 2=0 then inc(dem1)

else inc(dem2);

end;

writeln('So luong so chan la: ',dem1);

writeln('So luong so le la: ',dem2);

t:=0;

s:=1;

for i:=1 to n do 

  begin

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

if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];

end;

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

writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);

writeln('Cac so le la: ');

for i:=1 to n do 

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

writeln;

writeln('Cac so chan va lon hon 10 la: ');

for i:=1 to n do 

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

readln;

end.

Bình luận (1)