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
Nguyễn Lưu Khánh Hằng
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 4 2022 lúc 22:12

#include <bits/stdc++.h>

using namespace std;

long long a[100],i,n,x,dem;

int main()

{

cin>>n;

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

cin>>x;

dem=0;

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

if (x==a[i]) dem++;

cout<<dem;

return 0;

}

Tali
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 5 2021 lúc 9:40

Câu 4: 

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 (10<a[i]) and (a[i]<20) then 

begin

inc(dem);

t:=t+a[i];

end;

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

writeln('Tong cac phan tu lon hon 10 va nho hon 20 la: ',t);

readln;

end.

Nguyễn Lê Phước Thịnh
17 tháng 5 2021 lúc 9:41

Câu 5:

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. 

Mẫn Kim Anh
Xem chi tiết
Kiều Vũ Linh
28 tháng 4 2023 lúc 9:31

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

i,n,min: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;

writeln('Tong la ',s);

min:=a[1];

for i:=2 to n do

if a[i] < min then min:=a[i];

write('Cac so chan la ');

for i:=1 to n do

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

writeln;

write('so nho nhat la ',min);

readln

end.

Nhi Uyển
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 1 2022 lúc 11:37

#include <bits/stdc++.h>

using namespace std;

double b[100],x,ln,t;

int i,n,dem;

int main()

{

cin>>n;

ln=-1e10;

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

{

cin>>b[i];

ln=max(ln,b[i]);

}

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

cout<<b[i]<<" ";

cout<<endl;

cout<<ln<<endl;

t=0;

dem=0;

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

if (a[i]>x) 

{

t=t+a[i];

dem++;

}

cout<<fixed<<setprecision(2)<<t/(dem*1.0);

return 0;

}

Võ Ngọc Huy
Xem chi tiết
Anh Thư
Xem chi tiết
Minh Lệ
10 tháng 4 2021 lúc 18:25

Program HOC24;

var d,i,n: integer;

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

t: longint;

function nt(x: longint): boolean;

var j: longint;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

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

for i:=1 to n do

begin

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

end;

d:=0; t:=0;

for i:=1 to n do

if nt(a[i]) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' so nguyen to trong day');

write('Tong cac so nguyen to trong day la: ',t);

readln

end.

Nguyễn Lê Phước Thịnh
10 tháng 4 2021 lúc 20:18

uses crt;

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

i,n,dem,t,j,kt: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]>1 then 

begin

kt:=0;

for j:=2 to a[i]-1 do 

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

if kt=0 then

begin

inc(dem);

t:=t+a[i];

end;

end;

writeln('So luong so nguyen to la: ',dem);

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

readln;

end.

Võ Phan Xuân Trung
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 3 2022 lúc 20:20

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,dem;

int main()

{

cin>>n;

dem=0;

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

{

cin>>x;

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

}

cout<<dem;

return 0;

}

Nguyễn Ngọc
Xem chi tiết
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.