Những câu hỏi liên quan
ttrr
Xem chi tiết
Minh Lệ
12 tháng 4 2022 lúc 19:27

Program HOC24;

var i,d,n,x: integer;

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

begin

write('Nhap so phan tu: '); readln(n);

for i:=1 to n do 

begin

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

end;

write('Nhap x: '); readln(x);

d:=0;

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

write(d);

readln

end.

Bình luận (0)
Đặng Nguyễn Hoài Băng
Xem chi tiết

#include <bits/stdc++.h>
using namespace std;
int n,x,i,cnt,res;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>cnt;
for(i=0;i<n;i++)
{
    cin>>x;
    if(x%cnt==0) res++;
}
cout<<"so luong phan tu chia het cho "<<cnt<<" la: "<<res;
return 0;
}

 

 

Bình luận (0)

#include <bits/stdc++.h>
using namespace std;
const int gh=1000;
int n,x,i,cnt,res,dem[gh];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>cnt;
for(i=0;i<n;i++)
{
    cin>>x;
    if(x%cnt==0) { res++; dem[res]=x;}
}
cout<<"so luong phan tu chia het cho "<<cnt<<" la: "<<res;
cout<<"\n"<<"cac phan tu do la: "<<"\n";
for(i=1;i<=res;i++)
    cout<<dem[i]<<" ";
return 0;
}

// đây mới đúng mik đọc lỗi đề nha bạn!!

Bình luận (0)
nguyễn hoàng long
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 1 2022 lúc 22:00

#include <bits/stdc++.h>

using namespace std;

long long a[100],n,i,t,t1,dem,dem1;

//chuongtrinhcon

bool ktnt(long long x)

{

if (x<=1) return(false);

for (int i=2; i*i<=x; i++)

if (x%i==0) return(false);

return true;

}

//chuongtrinhchinh

int main()

{

cin>>n;

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

{

cin>>a[i];

}

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

t=0;

for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];

cout<<t<<endl;

dem=0;

for (i=1; i<=n; i++) if (a[i]%3==0) dem++;

cout<<dem<<" ";

t1=0;

dem1=0;

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

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

{

t1+=a[i];

dem1++;

}

cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;

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

if (ktnt(a[i])==true) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Thảo Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 12 2021 lúc 10:41

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

t=0;

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

{

cin>>a[i];

t=t+a[i];

}

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

dem=0;

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

if (a[i] %2==0) dem++;

cout<<dem<<endl;

cout<<t;

return 0;

}

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

uses crt;

var a:array[1..10]of longint;

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

begin

clrscr;

readln(n);

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

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

writeln;

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

Bình luận (0)
zero
20 tháng 1 2022 lúc 14:08

B

Bình luận (1)
Chanh Xanh
20 tháng 1 2022 lúc 14:08
Bình luận (1)
Nguyễn tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:08

uses crt;

var a:array[1..10]of longint;

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

begin

clrscr;

readln(n);

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

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

writeln;

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

Bình luận (0)
Phụng Lã
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 12 2022 lúc 14:42

#include <bits/stdc++.h>

using namespace std;

int A[500],n,i,dem,dem1;

int main()

{

cin>>n;

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

for (int i=n; i>=1; i--) cout<<A[i]<<" ";

cout<<endl;

dem=0;

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

if (A[i]<10) dem++;

cout<<dem<<endl;

dem1=0;

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

if (A[i]>1)

{

bool kt=true;

for (int j=2; j*j<=A[i]; j++)

if (A[i]%j==0) kt=false;

if (kt==true) dem1++;

}

cout<<dem1;

return 0;

}

Bình luận (0)
An Thuyên Đỗ
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 12 2022 lúc 16:20

#include <bits/stdc++.h>

using namespace std;

int n,A[100],i,k,t;

int main()

{

cin>>n>>k;

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

t=0;

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

if (A[i]%k==0) t+=A[i];

cout<<t;

}

Bình luận (0)
Huy Hoàng Phạm
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 12 2021 lúc 8:06

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[10000];

int main()

{

cin>>n;

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

cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)