关于算法的问题
我想做一个输入N之后的出来N个9到0的数 程序代码:
Clear Set Escape On Input To N m=Replicate("9",N) a=Right(m,1) j=1 g=0 For i=Val(a) To 0 Step -1 IF j=1 x=Substr(m,1,N-j-1)+Substr(m,N-j,1)+Alltrim(Str(i)) ELSE IF j= n x=Substr(m,N-j+1,2)+Alltrim(Str(i)) else x=Substr(m,1,N-j)+Substr(m,N-j+1,1)+Alltrim(Str(i)) endif endif If Alltrim(Str(i))='0' ?Transform(x) Endif If i=0 If Val(Substr(x,N-j+1,1))-1=-1 &&判断将要减1的位数是否为0 For u=j+1 To N Step +1 If Val(Substr(x,N-u+1,1))-1<>-1 &&判断将要减1的位数是否为0 g=u z=Replicate("9",u-1) x=Alltrim(Substr(x,1,N-u))+Alltrim(Str(Val(Substr(x,N-u+1,1))-1))+z m=x u=N+1 j=j+1 i=9 Endif Endfor *!* ELSE *!* if Val(Substr(x,N-g+2,1))-1<>-1 *!* z=Replicate("9",g-2) *!* x=Alltrim(Substr(x,1,N-g+1))+Alltrim(Str(Val(Substr(x,N-g+2,1))-1))+z *!* i=9 *!* m=x *!* else *!* z=Replicate("9",g-1) *!* x=Alltrim(Substr(x,1,N-g))+Alltrim(Str(Val(Substr(x,N-g+1,1))-1))+z *!* i=9 *!* m=x *!* endif ENDIF endif ?Transform(x) Next
真的想不出来..有大侠能帮帮忙么。