pascal代码:
[code:1]
program Zhiyinshu;
Var
n,i:longint;
begin
writeln('分解质因数 by TML);
writeln('Build date:1/1/2004');
write(' 输入要分解的整数:');
readln(n);
i:=2;
write(' 结果:');
write(n);
{控制n=1时的输出}
if n=1 then begin
write('=1');
readln;
halt;
end;
{控制n=-1时的输出}
if n=-1 then begin
write('=-1');
readln;
halt;
end;
{控制n=0时的输出}
if n=0 then begin
write('=0');
readln;
halt;
end;
{当n<0时,先输出一个负号}
if n<0 then begin
write('=-');
n:=-n;
end
else
write('=');
while i<=n do
if n mod i=0 then begin
write(i);
if n/i<>1 then write('*');
n:=n div i;
i:=2;
end
else
i:=i+1;
readln;
end.
[/code:1]