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 n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++) if (n%i==0) cout<<i<<" ";
return 0;
}
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chan la: ');
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
writeln;
writeln('Cac so le la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
writeln('Cac so chia het cho 3 la: ');
for i:=1 to n do
if a[i] mod 3=0 then write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so o vi tri chan la: ');
for i:=1 to n do
if i mod 2=0 then write(a[i]:4);
writeln;
writeln('Cac so o vi tri le la: ');
for i:=1 to n do
if i mod 2=1 then write(a[i]:4);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
const long long maxint=1000000;
bool a[maxint];
long long n,i,j;
int main()
{
cin>>n;
for (i=2; i<=n;i++)
a[i]=true;
for (i=2;i<=n; i++)
if (a[i]==true)
{
for (j=i*i;j<=n;j+=i)
a[j]=false;
}
for (i=2; i<=n; i++)
if (a[i]==true) cout<<i<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
if (i%2==0) cout<<i<<" ";
cout<<endl;
for (i=1; i<=n; i++)
if (i%2==1) cout<<i<<" ";
cout<<endl;
}
1.
Program bai1;
uses crt;
var n,i: integer;
begin
clrscr;
write('nhap so n ='); readln(n);
for i := 1 to n do
if n mod i = 0 then
write(i :2 , ' , ');
readln;
end.
2.
program bai2;
uses crt;
var i,n: integer;
begin
clrscr;
write('nhap so n ='); readln(n);
for i: 1 to n do
if i mod 2 = 0 then
write(i: 3 ,',');
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,min,dem,dem1:integer;
begin
clrscr;
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
writeln;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln('Phan tu nho nhat la: ',min);
dem:=0;
writeln('Cac so le trong day la: ');
for i:=1 to n do
if a[i] mod 2<>0 then
begin
write(a[i]:4);
inc(dem);
end;
writeln;
writeln('So phan tu le la: ',dem);
writeln('Cac phan tu chan la: ');
dem1:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i]:4);
inc(dem1);
end;
writeln;
writeln('So phan tu chan la: ',dem1);
readln;
end.
uses crt;
var n,i,d,x,j,tam:longint;
a:array[1..255]of longint;
st:string;
begin
clrscr;
write('Nhap n='); readln(n);
str(n,st);
d:=length(st);
for i:=1 to d do
val(st[i],a[i],x);
for i:=1 to d-1 do
for j:=i+1 to d do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to d do
write(a[i]);
readln;
end.