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;
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!!
#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;
}
#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;
}
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.
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.
program HienThiSoChan;
var
N, i: integer;
A: array[1..50] of integer;
begin
writeln('Nhap so nguyen duong N:');
readln(N);
writeln('Nhap day so A gom ', N, ' phan tu:');
for i := 1 to N do
begin
readln(A[i]);
if A[i] mod 2 = 0 then
begin
writeln('Phan tu thu ', i, ' la so chan: ', A[i]);
end;
end;
readln;
end.
uses crt;
var a: array[1..10000] of longint;
i,n:integer;
begin clrscr;
write('Nhap n: ');readln(n);
for i:=1 to n do read(a[i]); writeln('Cac phan tu chia het cho 3 va 5 la: ');
for i:=1 to n do
if (a[i] mod 3 = 0) and (a[i] mod 5=0) then writeln(a[i],' - vi tri thu ',i);
readln
end.
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.
Program HOC24;
var n,d,i: integer;
B: array[1..100] of integer;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
d:=0; t:=0;
for i:=1 to n do
if b[i]>0 then
begin
d:=d+1;
t:=t+b[i];
end;
writeln('Tong cac so duong trong day so la: ',t);
write('Co ',d,' so duong trong day');
readln
end.
uses crt;
var b:array[1..100] of longint;
n,i,d,s:longint;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']: '); readln(b[i]);
if b[i]>0 then begin
inc(d);
inc(s,b[i]);
end;
end;
writeln('Tong cac so duong: ',s);
writeln('Co ',d,' so duong');
readln;
end.
Var a:array:[1..1000] of integer;
i,n,max:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
End;
Write('Cac diem vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
max:=a[1];
For i:=2 to n do
if a[i] > max then max:=a[i];
write('So lon nhat la ',max);
Readln
End.
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.