主题:大家来帮帮我吧!!!!!!
huangxixixi
[专家分:30] 发布于 2005-06-11 16:41:00
输入一个大于1的自然数,打印出它的质因数解式。如输入75则打印:75=3*5*5
请帮帮我!!!!!!!!
我十二分感谢!!!
回复列表 (共4个回复)
沙发
zhsas [专家分:1680] 发布于 2005-06-12 01:31:00
program zhs (input,output);
var
x,y,i,n:integer;
begin
read(x);
write(x:3,'=');
y:=2;
n:=1;
repeat
if x mod y = 0
then begin
x:=x div y;
if n <> 1
then write('*');
write(y:2);
n:=2
end
else y:=y+1
until x=1;
writeln
end.
板凳
泡泡糖 [专家分:230] 发布于 2005-06-12 13:35:00
program lt;
var n,s,i:integer;
begin
write('N=');readln(n);
s:=n;
for i:=2 to n do
begin
repeat
if s mod i=0 then begin s:=trunc(s/i);
write(i);if s<>1 then write('*'); end;
until (s mod i<>0);
end;
writeln;
end.
3 楼
QQ331373582 [专家分:1500] 发布于 2005-06-14 21:01:00
program lt;
var n,s,i:integer;
begin
write('N=');readln(n);
s:=n;
for i:=2 to n do
begin
repeat
if s mod i=0 then begin s:=trunc(s/i);
write(i);if s<>1 then write('*'); end;
until (s mod i<>0);
end;
writeln;
end.
4 楼
relative660 [专家分:260] 发布于 2005-06-14 22:50:00
算法效率太低!循环只要到根号n就可以了
我来回复