怎样才能用a到z 或 A到Z 排列?(50分)

I

ifbn

Unregistered / Unconfirmed
GUEST, unregistred user!
例如:从aa开始+1变为ab.....到az , +1进位变为ba ....... 到zz然后+1进位为baa 以此类推。

怎样才能实现这样排序???
 
你这个疯子害死我了,浪费我半个小时!应该正确。
procedure crazy;
var str:String;
i,j,len,LoopCount:Integer;
begin
str:='aa';
len:=2;
LoopCount:=100;
for i:=1 to LoopCountdo
begin
j:=len;
str[j]:=chr(ord(str[j])+1);
while (ord(str[j])>ord('z'))and (j>1)do
begin
str[j]:='a';
dec(j);
str[j]:=chr(ord(str[j])+1);
end;
if ord(str[1])>ord('z') then
begin
len:=len+1;
str:=str+' ';
for j:=lendo
wnto 2 do
str[j]:=str[j-1];
str[1]:='a';

end;

end;
showMessage(str);
end;
end;
 
这是老师的作业题吧??
:)
 
agree above
 
上面的代码有一点问题,将
if ord(str[1])>ord('z') then
begin
len:=len+1;
str:=str+' ';
for j:=lendo
wnto 2 do
str[j]:=str[j-1];
str[1]:='a';

end;

改为

if ord(str[1])>ord('z') then
begin
len:=len+1;
str:=str+' ';
for j:=lendo
wnto12 do
str[j]:='a';

end;

 
接受答案了.
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
962
SUNSTONE的Delphi笔记
S
S
回复
0
查看
784
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
顶部