Những câu hỏi liên quan
Quỳnh Anh Đào
Xem chi tiết
Đặ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)
Linh Chi
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 3 2021 lúc 19:40

uses crt;

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

n,i,k,dem,dem1:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

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

dem:=0;

dem1:=0;

for i:=1 to n do 

  begin

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

if a[i] mod k=0 then inc(dem1);

end;

writeln('So phan tu chan la: ',dem);

writeln('So phan tu chia het cho ',k,' la: ',dem1);

readln;

end.

Bình luận (0)
Nguyệt Ánh
Xem chi tiết
Phía sau một cô gái
7 tháng 5 2023 lúc 19:53

A = [  ]

for i in range(20):

        A.append(int(input("Nhập phần tử thứ " + str(i+1) + ": ")))

tong = sum(A)

trung_binh = tong / len(A)

print("Mảng A =", A)

print("Giá trị trung bình của mảng A là", trung_binh)

Bình luận (0)
Đỗ trung học
Xem chi tiết
Khavid Ngô
15 tháng 3 2021 lúc 20:51

Bình luận (0)
Nguyễn Lê Phước Thịnh
15 tháng 3 2021 lúc 20:52

const fi='dl.pas'

fo='qk.pas'

var f1,f2:text;

i,n,dem,t,dem1,dem2,kt,j:integer;

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

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

dem:=0;

for i:=1 to n do 

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

t:=0;

for i:=1 to n do

  if (10<=a[i]) and (a[i]<=30) then t:=t+a[i];

dem1:=0;

for i:=1 to n do 

  if (a[i]<0) and (a[i] mod 2<>0) then inc(dem1);

dem2:=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 inc(dem2);

end;

writeln(f2,'So phan tu le chia het cho 7 la: ',dem);

writeln(f2,'Tong cac phan tu thuoc [10,30] la: ',t);

writeln(f2,'So cac phan tu am le la: ',dem1);

writeln(f2,'So phan tu la so nguyen to la: ',dem2);

close(f1);

close(f2);

end.

Bình luận (0)
hùng tín trang
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 15:18

undefined

Bình luận (0)
29_LÃ XUÂN SƠN
Xem chi tiết
No No
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 4 2022 lúc 14:06

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

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

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

cout<<t;

return 0;

}

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

#include <bits/stdc++.h>

using namespace std;

long long a[20],n=20,i,dem,t,s;

int main()

{

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

dem=0;

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

t=0;

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

s=1;

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

if (a[i]%7==0) s*=a[i];

cout<<dem<<endl;

cout<<t<<endl;

cout<<s;

return 0;

}

Bình luận (0)