Những câu hỏi liên quan
Quân Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 12 2020 lúc 20:57

Câu 1: 

uses crt;

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

i,n,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

  end;

t:=0;

for i:=1 to n do 

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

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

readln;

end.

Câu 2: 

uses crt;

var c,a:array[1..10]of integer;

i,kt,j,dem:integer;

begin

clrscr;

for i:=1 to 10 do 

  begin

write('C[',i,']='); readln(c[i]);

end;

dem:=0;

for i:=1 to 10 do 

  if c[i]>1 then 

begin

kt:=0;

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

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

if kt=0 then 

begin

inc(dem);

a[dem]:=c[i];

end;

end;

if dem=0 then writeln('Trong day khong co so nguyen to')

else begin

writeln('Cac so nguyen to trong day la: ');

for i:=1 to dem do

write(a[i]:4);

end;

readln;

end.

Câu 3: 

uses crt;

var d:array[1..200]of integer;

i,k,dem:integer;

begin

clrscr;

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

for i:=1 to k do 

  begin

write('D[',i,']='); readln(d[i]);

end;

dem:=0;

for i:=1 to k do 

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

writeln('So phan tu chan co 2 chu so la: ',dem);

readln;

end.

Bình luận (0)
Anh Lê duy
Xem chi tiết
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)
Đặ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)
Hiểu Nguyễn Đức
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 5 2022 lúc 14:17

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem,t,j,t1;

int main()

{

cin>>n;

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

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

cout<<endl;

dem=0;

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

{

t=0;

for (j=1; j<=a[i]-1; j++)

if (a[i]%j==0) t+=j;

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

}

cout<<dem<<endl;

t1=0;

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

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

cout<<t1;

return 0;

}

Bình luận (0)
Kudo Shinichi
25 tháng 5 2022 lúc 19:31

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem,t,j,t1;

int main()

{

cin>>n;

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

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

cout<<endl;

dem=0;

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

{

t=0;

for (j=1; j<=a[i]-1; j++)

if (a[i]%j==0) t+=j;

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

}

cout<<dem<<endl;

t1=0;

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

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

cout<<t1;

return 0;

}

Bình luận (0)
Hiểu Nguyễn Đức
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 5 2022 lúc 14:17

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem,t,j,t1;

int main()

{

cin>>n;

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

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

cout<<endl;

dem=0;

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

{

t=0;

for (j=1; j<=a[i]-1; j++)

if (a[i]%j==0) t+=j;

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

}

cout<<dem<<endl;

t1=0;

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

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

cout<<t1;

return 0;

}

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)
Ẩn Nguyen
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 3 2021 lúc 12:45

uses crt;

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

i,n,dem:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

dem:=0;

for i:=1 to n do

  if (a[i] mod 3=0) and (a[i] mod 5=0) then inc(dem);

writeln('So phan tu chia het cho 3 va 5 trong day la: ',dem);

readln;

end.

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)