viết chương trình tìm tất cả số có 3 chữ số sao cho tổng các chữ số bằng tích của chúng.Làm pascal
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.
Gọi số đó là abc ta có abc=a+b+c. Giả sử \(9\ge a\ge b\ge c\ge0\) thì \(abc=a+b+c\le3a\) suy ra \(bc\le3\)
abc khác 0 (vì \(a\ge1\) nên a+b+c\(\ge1\))
bc=3 thì b=3, c=1, suy ra 3+1+a=3a suy ra a=2 (loại, vì a bé hơn b)
bc=2 => b=2, c=1 suy ra 3+a=2a suy ra a=3 (Chọn)
bc=1 => b=1, c=1 suy ra 2+a=a (loại)
Vậy Các số cần tìm là 123, 132, 213, 231, 312, 321
Đừng lấy bài của thằng Nyễn Khắc Vinh , nó lúc nào cũng 4545 , ko thì 454 , ....
Tổng 3 chữ số của số bé nhất có 3 chữ số có tích 3 chữ số bằng 3 là ?
hihiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii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iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii cấm đọc tiếp
địt lồn mẹ mày bú buồi đầu buồi liếm lông chim
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 x,y,z,n : integer;
begin clrscr;
write('Nhap n:'); readln(n);
for x:=1 to 9 do
for y:=0 to 9 do
for z:=0 to 9 do
if n*(x+y+z) = x*100+y*10+z then
write('So thoa man de la :', x,y,z, ' ');
readln
end.
a) 102; 111; 120; 210; 201; 300
b) 4000 3100 3010 3001 2002 2020 2200 2011 2101 2110 1111 1003 1030 1300 1210 1201 1120 1102 1012 1021 v.v..
Nếu thiểu bổ sung hộ mk.
uses crt;
var a,b,c:integer;
begin
clrscr;
for a:=1 to 9 do
for b:=0 to 9 do
for c:=0 to 9 do
if (a+b+c=a*b*c) then writeln(a,b,c,' ');
readln;
end.
đúng ko vậy bn