pascal问题(附上注解)

2024-12-03 09:03:19
推荐回答(2个)
回答1:

1、
var n,i:integer;
l:longint;
begin
readln(n); 输入n
l:=1;
for i:=2 to n do 求阶乘
l:=l*i;
writeln(l); 输出
end.

请把第二题说清楚

回答2:

var i,l,x,max,min,k,j:integer;
st1,st2:string[4];
ch:char;
begin
while not eof do begin
readln(x);
k:=1;
repeat
str(x,st1); l:=length(st1);
if l<4 then st1:=copy(st1+'0000',1,4);
for i:=1 to 3 do
for j:=i+1 to 4 do
if st1[i] begin
ch:=st1[i];
st1[i]:=st1[j];
st1[j]:=ch;
end;
st2:=st1;
for i:=1 to 4 do st2[5-i]:=st1[i];
val(st1,max);
val(st2,min);
x:=max-min;
writeln(max,'-',min,'=',x);
until x=6174;
end;
end.