- 卡布列克圆舞曲
- 2009-11-06 10:22:31 @
如题,神牛们帮我看看啊
var a,c,d,e,i,j,k,m,n,l:longint;
s,s1,s2,s3:string;
g:char;
b:array[0..10000]of longint;
function f(e:longint):boolean;
var k:integer;
begin
for k:=0 to n do if e=b[k] then begin f:=true;m:=k;break;end
else f:=false;
end;
begin
while not eof do begin
readln(a);
fillchar(b,sizeof(b),0);
e:=a;
n:=0;
str(a,s1);
l:=length(s1);
while not f(e) do begin
inc(n);b[n]:=e;
str(e,s);
while length(s)l do s:='0'+s;
s2:='';
for i:=1 to l-1 do
for j:=i to l do begin
if s[i]>s[j] then begin
g:=s[i];
s[i]:=s[j];
s[j]:=g;
end;
end;
for i:=1 to l do begin
s2:=s2+s[l-i+1];
end;
val(s,c);
val(s2,d);
e:=d-c;
end;
for i:=m to n-1 do write(b[i],' ');
write(b[n]);
end;
end.
1 条评论
-
wnzh LV 8 @ 2009-11-06 11:37:11
字符串处理麻烦
但我用数组处理更麻烦大囧
http://hi.baidu.com/difficult%5Fac/blog/item/802e16121c8417085aaf5381.html
- 1