Những câu hỏi liên quan
Yna Lolipop
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 3 2022 lúc 23:11

1:

#include <bits/stdc++.h>

using namespace std;

long long dem,i,n,x;

int main()

{

cin>>n;

dem=0;

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

{

cin>>x;

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

}

cout<<dem;

return 0;

}

Câu 2: 

#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%3==0) t+=x;

}

cout<<t;

return 0;

}

Bình luận (0)
Trang
Xem chi tiết
Minh Lệ
9 tháng 5 2023 lúc 13:37

Program HOC24;

var i,n,d: integer;

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

begin

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

for i:=1 to n do

begin

write('Nhap so thu ',i,': '); readln(a[i]);

end;

d:=0;

for i:=1 to n do if a[i] mod 5<>0 then d:=d+1;

write('Co ',d,' so khong chia het cho 5');

readln

end.

Bình luận (0)
Huy Phạm
Xem chi tiết
Kiều Vũ Linh
3 tháng 5 2023 lúc 6:12

1)

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

i,n,t:integer;

Begin

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

For i:=1 to n do

Begin

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

End;

For i:=1 to n do

If a[i] > a[i+1] then

Begin

t:=a[i];

a[i]:=a[i+1];

a[i+1]:=t;

End;

Write('Sap xep tang dan ');

For i:=1 to n do write(a[i]:8);

Readln

End.

Bình luận (0)
Kiều Vũ Linh
3 tháng 5 2023 lúc 6:13

2)

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

i,n,t:integer;

Begin

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

For i:=1 to n do

Begin

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

End;

For i:=1 to n do

If a[i] < a[i+1] then

Begin

t:=a[i];

a[i]:=a[i+1];

a[i+1]:=t;

End;

Write('Sap xep giam dan ');

For i:=1 to n do write(a[i]:8);

Readln

End.

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

Câu 1: 

uses crt;

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

i,n,t,s:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=0;

s:=1;

dem:=0;

for i:=1 to n do 

  if a[i] mod 3=0 then 

begin

inc(dem);

t:=t+a[i];

s:=s*a[i];

end;

if dem=0 then writeln('Khong co so chia het cho 3 trong day')

else begin

writeln('Tong cac so chia het cho 3 la: ',t);

writeln('Tich cac so chia het cho 3 la: ',s);

end;

readln;

end.

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

Câu 2: 

uses crt;

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

i,n,dem,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem:=0;

t:=0;

for i:=1 to n do 

 if a[i] mod 2=0 then 

begin

inc(dem);

t:=t+a[i];

end;

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

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

readln;

end.

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

Câu 3: 

uses crt;

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

i,n,dem1,dem2,t1,t2,s1,s2:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem1:=0;

dem2:=0;

t1:=0;

t2:=0;

s1:=1;

s2:=1;

for i:=1 to n do

begin

if a[i] mod 2=0 then 

begin

inc(dem1);

t1:=t1+a[i];

s1:=s1*a[i];

end

else begin

inc(dem2);

t2:=t2+a[i];

s2:=s2*a[i];

end;

end;

if dem1=0 then writeln('Khong co so chan trong day')

else begin

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

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

writeln('Tich cac so chan la: ',s1);

end;

if dem2=0 then writeln('Khong co so le trong day')

else begin

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

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

writeln('Tich cac so le la: ',s2);

end;

readln;

end.

Bình luận (0)
nam bảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 3 2022 lúc 14:01

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,t;

int main()

{

cin>>n;

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

t=0;

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

if (i%2!=0) t+=a[i]*a[i];

cout<<t<<endl;

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

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

cout<<endl;

sort(a+1,a+n+1);

for (i=n; i>=1; i--)

cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Nguyễn Quang Đạt
Xem chi tiết
Nguyên Hưng Trần
26 tháng 7 2021 lúc 20:42

Program Tin_hoc;

uses crt;

var n,i,dem:integer;

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

Begin

clrscr;

readln(n);

dem:=0;

for i:= 1 to n do 

  Begin

  readln(a[i]);

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

  end;

writeln('Day so co ',dem,' so chan');

readln;

end.

Bình luận (0)
Nguyễn Quang Đạt
Xem chi tiết
Nguyên Hưng Trần
22 tháng 7 2021 lúc 20:55

uses crt;

Var i,n,dem:integer;

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

Begin

clrscr;

Write('Nhap do dai cua day: ');readln(n);

dem:=0;

for i:= 1 to n do

  Begin

  write('So thu ',i,' = ');

  readln(a[i]);

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

  end;

Writeln('Day so co ',dem,' so chan');

readln;

End.

Bình luận (0)
Nguyễn Quang Đạt
Xem chi tiết
Nguyên Hưng Trần
22 tháng 7 2021 lúc 20:55

uses crt;

Var i,n,dem:integer;

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

Begin

clrscr;

Write('Nhap do dai cua day: ');readln(n);

dem:=0;

for i:= 1 to n do

  Begin

  write('So thu ',i,' = ');

  readln(a[i]);

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

  end;

Writeln('Day so co ',dem,' so chan');

readln;

End.

Bình luận (0)
Nguyễn Quang Đạt
Xem chi tiết
Nguyên Hưng Trần
22 tháng 7 2021 lúc 20:55

uses crt;

Var i,n,dem:integer;

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

Begin

clrscr;

Write('Nhap do dai cua day: ');readln(n);

dem:=0;

for i:= 1 to n do

  Begin

  write('So thu ',i,' = ');

  readln(a[i]);

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

  end;

Writeln('Day so co ',dem,' so chan');

readln;

End.

Bình luận (0)
phạm quang huy
6 tháng 8 2021 lúc 20:08

uses crt;

var i,n,dem:longint;a:array[1..1000]of longint;

begin

clrscr;

write('nhap so phan tu cua day:');readln(n);

for i:=1 to n do

begin

write('nhap phan tu thu',i,'=');readln(a[i]);

end;

for i:=1 to n do if(a[i] mod 2=0)then inc(dem);

writeln('co tat ca:',dem,'so chan');

readln;

end.

 

Bình luận (0)