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.
2:
#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..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.
program vdd;
uses crt;
var i,n: integer;
begin
clrscr;
write('Nhap N: '); readln(n);
for i:=1 to n do if i mod 2=1 then write(i,';');
readln
end.
#include <bits/stdc++.h>
using namespace std;
int n,t,i;
int main()
{
cin>>n;
t=1;
for (int i=1; i<=n; i++)
if (i%2==0) t*=i;
cout<<t;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,t,dem;
int main()
{
cin>>n;
t=0;
dem=0;
for (i=1; i<=n; i++)
if (i%2==1)
{
t=t+i;
dem++;
}
cout<<fixed<<setprecision(2)<<(t*1.0)/(dem*1.0);
return 0;
}
Program xuatmatranxoanoc;
uses crt;
var a:array[1..100,1..100] of Integer;
d,i,j,n:integer;
Begin
clrscr;
d:=0;
i:=0;
write('Nhap n:'); readln(n);
repeat
i:=i+1;
for j:=i to n-i do
begin
d:=d+1;
a[i,j]:=d;
end;
for j:=i to n-i do
begin
d:=d+1;
a[j,n+1-i]:=d;
end;
for j:=i to n-i do
begin
d:=d+1;
a[n+1-i,n+1-j]:=d;
end;
for j:=i to n-i do
begin
d:=d+1;
a[n+1-j,i]:=d;
end;
until d>=n*n-1;
if n mod 2=1 then a[(n+1) div 2,(n+1) div 2]:=n*n;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:4,' ');
writeln;
end;
readln;
End.