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 <iostream>
using namespace std;
int tong=0,x[1001],tongcs=0;
void xuli(int i)
{
for(int j=0;j<=9;j++)
{
if(j==0&&i==1)
continue;
x[i]=j;
tong*=10;
tong+=j;
tongcs+=j;
if(i==3)
{
if(tong%6==2&&tongcs==20)
{
cout<<tong<<endl;
}
}
else
{
xuli(i+1);
}
tongcs-=j;
tong-=j;
tong/=10;
}
}
int main()
{
xuli(1);
return 0;
}
uses crt;
var i,t,d,x,y,j:integer;
st:string;
begin
clrscr;
writeln('cac so tu nhien co 3 chu so sao cho so do chia cho 6 du 2 va tong cac chu so la 20 gom cac so:');
for i:=100 to 999 do
begin
t:=0;
str(i,st);
d:=length(st);
for j:=1 to d do
begin
val(st[j],x,y);
t:=t+x;
end;
if (i mod 6=2) and (t=20) then write(i:6);
end;
readln;
end.
program so_hoan_hao;
var
n, tong_uoc, i: integer;
begin
writeln('Nhap vao mot so nguyen duong n:');
readln(n);
tong_uoc := 0;
for i := 1 to n-1 do
begin
if n mod i = 0 then
tong_uoc := tong_uoc + i;
end;
if tong_uoc = n then
writeln('YES')
else
writeln('NO');
end.
uses crt;
var n,i,d,dem,kt,t,kt1,t1,t2,t3,max,min,x,j:integer;
a,b:array[1..100]of integer;
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);
dem:=1;
b[1]:=a[1];
for i:=1 to d do
begin
kt:=0;
for j:=1 to dem do
if a[i]=b[j] then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
writeln('Cac chu so cua ',n,' la: ');
for i:=1 to dem do
write(b[i]:4);
writeln;
t:=0;
for i:=1 to d do
t:=t+a[i];
writeln('Tong cac chu so cua ',n,' la: ',t);
kt1:=0;
for i:=2 to trunc(sqrt(t)) do
if t mod i=0 then
begin
kt1:=1;
break;
end;
if (kt1=0) and (t>1) then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
writeln('Cac chu so o vi tri le cua ',n,' la: ');
t1:=0;
for i:=1 to d do
if i mod 2=1 then
begin
write(a[i]:4);
t1:=t1+a[i];
end;
writeln;
writeln('Tong cac chu so o vi tri le la: ',t1);
if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')
else writeln(t1,' khong la so chinh phuong');
writeln('Cac chu so o vi tri chan cua ',n,' la: ');
t2:=0;
for i:=1 to d do
if i mod 2=0 then
begin
write(a[i]:4);
t2:=t2+a[i];
end;
writeln('Tong cac chu so o vi tri chan la: ',t2);
t3:=0;
for i:=1 to t2 do
if t2 mod i=0 then t3:=t3+i;
if (t3=t2) and (t2>0) then writeln(t2,' la so hoan hao')
else writeln(t2,' khong la so hoan hao');
max:=a[1];
min:=a[1];
for i:=1 to d do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Chu so lon nhat cua ',n,' la: ',max);
writeln('Chu so nho nhat cua ',n,' la: ',min);
writeln('Tong cua chung la: ',max+min);
readln;
end.
uses crt;
var n,kt,snt,b,m:longint;
{-----------------------------}
procedure nhap(var a:longint);
begin
write('nhap n:'); readln(a);
end;
{-------------------------------------------}
function ktnt(var x:longint):integer;
var kt,i,kt1,j:integer;
begin
kt:=0;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then
begin
kt:=1;
break;
end;
if kt=0 then ktnt:=1
else ktnt:=0;
end;
{-----------------------------------------------------}
BEGIN
clrscr;
nhap(n);
for m:=10 to n do
{-----------------------------------------------}
begin
begin
b:=m;
repeat
kt:=ktnt(b);
if kt=0 then break
else b:=b div 10;
until b<10;
if (ktnt(b)=1) and (b>1) then write(m,' ')
end;
end;
{-------------------------------------------------}
readln;
END.
program ct;
uses crt;
var dem,n,s,max,t:longint;
begin
writeln('nhap n:');readln(n);
while n>0 do begin
s:=n mod 10;
t:=t+s;
if max<s then max:=s;
dem:=dem+1;
n:=n div 10;
end;
writeln('tong la',t,',','co',' ',dem,' ','chu so',',','chu so lon nhat la:',max);
readln
end.
bạn xem lại nha mik làm đây nhưng k bt đk
uses crt;
var i,n,d:longint;
begin
d:=0;
writeln('nhapn=');read(n);
for i:=1 to n do
begin
if i mod 3=0 then write(i,' ');
if i mod 3=0 then d:=d+i;
end;
writeln('tong=',d);
readln;
end;
1:
uses crt;
var i,j,t,kt:integer;
begin
clrscr;
t:=0;
for i:=1 to 100 do
if i>1 then
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then t:=t+i;
end;
writeln(t);
readln;
end.
Câu 2:
*Viết chương trình:
uses crt;
var n,p,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for p:=2 to n-1 do
if n mod p=0 then t:=t+p;
writeln('Tong cac uoc that su cua ',n,' la: ',t);
readln;
end.
chương trình tham khảo ...