K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,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 (a[i]%x==0)

{

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

dem++;

}

cout<<endl;

cout<<dem;

return 0;

}

12 tháng 4 2022

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.

#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;
}

 

 

#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!!

27 tháng 4 2023

Làm như z có đg ko

Uses crt;

Var n,i: integer;

A: Array[1..1000] of integer;

Begin

clrscr;

Repeat

Write('Nhap n: '); Readln(n);

Until (n<103) and (n>0);

a)

For i:=1 to n do

 begin

  Write('Nhap phan tu A[',i,']= ');

  Readln(A[i]);

 end;

b)

Write('Cac phan tu chan co trong mang: ');

For i:=1 to n do

 If A[i] mod 2=0 then write(A[i],' ');

writeln;

c)

Write('Cac phan tu le co trong mang: ');

For i:=1 to n do

 If A[i] mod 2=1 then write(A[i],' ');

Readln

End.

27 tháng 4 2023

Uses crt;

var i,n: longint;

a: array[1..103] of longint;

begin clrscr;

readln(n);

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

for i:=1 to n do if(a[i] mod 2=0) then write(a[i],'  ');

for i:=1 to n do if(a[i] mod 2<>0) then write(a[i],'  ');

readln;

end.

#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++) cout<<a[i]<<" ";

cout<<endl;

t=0;

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

cout<<t;

return 0;

}

8 tháng 5 2023

Var a:array:[1..50] of integer;

i:integer;

s:longint;

Begin

For i:=1 to 50 do

Begin

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

If a[i] mod 2 <> 0 then

s:=s+a[i];

End;

Write('Tong cac so le la: ',s);

Readln

End.

22 tháng 4 2022

Program HOC24;

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

i,n,d: integer;

tbc: real;

t: longint;

begin

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 t:=t+a[i];

writeln('Tong cac phan tu cua mang la: ',t);

d:=0; 

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

writeln('Co ',d,' phan tu co gia tri bang 5');

tbc:=0;

for i:=1 to n do if a[i] mod 2=1 then tbc:=tbc+a[i];

tbc:=tbc/n;

writeln('Trung binh cong cac phan tu le la: ',tbc:6:2);

write('Mang sau khi thay la: ');

for i:=1 to n do if a[i]=0 then a[i]:=10;

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

readln

end.

Uses crt;

Var a:array[1..6] of integer;

I,s:integer;

Begin

Clrscr;

For i:=1 to 6 do 

Begin

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

End;

S:=1;

For i:=1 to 6 do

If a[i] mod 3=0 then s:=s*a[i];

Writeln(s);

Readln;

End.