Những câu hỏi liên quan
nguyễn bùi hương giang
Xem chi tiết
Bùi Anh Tuấn
2 tháng 1 2021 lúc 20:58

Bình luận (0)
Nguyen Thanh Tam
Xem chi tiết
HUY
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 12 2022 lúc 15:37

#include <bits/stdc++.h>

using namespace std;

int n,s,i,t;

int main()

{

freopen("bai1.inp","r",stdin);

freopen("bai1.out","w",stdout);

cin>>n>>s;

t=0;

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

{

int x;

cin>>x;

if (x%s==0) t+=x;

}

cout<<t;

}

Bình luận (0)
huynh chinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:49

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

freopen("dayd.inp","r",stdin);

freopen("dayd.out","w",stdout);

cin>>n;

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

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

if (a[i]>0) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Phạm Gia Long
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 12 2021 lúc 11:49

#include <bits/stdc++.h>

using namespace std;

long long a[4],n,x;

int main()

{

cin>>n>>x;

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

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

if (a[i]==x)

{

cout<<"YES";

break;

}

cout<<"NO";

return 0;

}

Bình luận (0)
Nguyễn Xuân Dự
Xem chi tiết
Kiều Vũ Linh
12 tháng 5 2023 lúc 7:59

Bài 1

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

i,n:integer;

s:longint;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');readln(a[i]);

s:=s+a[i];

End;

Write('Cac so vua nhap la: ');

For i:=1 to n do 

Write(a[i]:8);

writeln;

write('Tong cac so la ',s);

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)
Sự tâm
Xem chi tiết
35 _ Lê Thị Mỹ Huyền
Xem chi tiết
Linh Thùy
23 tháng 10 2021 lúc 18:37

Cho số nguyên dương N và dãy số nguyên a1 ;a2 ...an đếm các số âm trong dãy số đó

 

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

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

t=t+x;

}

cout<<t;

return 0;
}

Bình luận (0)