Ch:=Chr(Ord('a')-4); if Ord(Ch)<65 then Ch:=Chr(Ord(Ch)+26);
procedure TForm1.Button1Click(Sender: TObject); var C: Char; I: Char; S: string; begin S := ''; for I := 'a' to 'z' do begin C:= I; Dec(C, 4); if not (C in ['a'..'z']) then Inc(C, 26); S := S + C; end; Caption := S; end;
function EncodeStr(s:String):String; var s1:String; i:integer; begin for i:=1 to Length(s) do begin s1[i]:=Chr(Ord(s[i])-4); if Ord(s1[i])<Ord('a') then s1[i]:=Chr(Ord(s1[i])+26); end; Result:=s1; end;
上述有误,改为以下 function EncodeStr(s:String):String; var s1:String; i:integer; begin SetLength(s1,Length(s)); for i:=1 to Length(s) do begin s1[i]:=Chr(Ord(s[i])-4); if Ord(s1[i])<Ord('a') then s1[i]:=Chr(Ord(s1[i])+26); end; Result:=s1; end;
for i:=1 to length (edit1.Text)do begin edit2.text:=edit2.text+copy(edit1.Text,i,1); str:=copy(edit1.Text,i,1);//拆分字符串,有什么错误吗? 我的怎么运行不了,怪了
if Ord(Ch)<65 then
Ch:=Chr(Ord(Ch)+26);
var
C: Char;
I: Char;
S: string;
begin
S := '';
for I := 'a' to 'z' do begin
C:= I;
Dec(C, 4);
if not (C in ['a'..'z']) then Inc(C, 26);
S := S + C;
end;
Caption := S;
end;
var s1:String;
i:integer;
begin
for i:=1 to Length(s) do
begin
s1[i]:=Chr(Ord(s[i])-4);
if Ord(s1[i])<Ord('a') then
s1[i]:=Chr(Ord(s1[i])+26);
end;
Result:=s1;
end;
function EncodeStr(s:String):String;
var s1:String;
i:integer;
begin
SetLength(s1,Length(s));
for i:=1 to Length(s) do
begin
s1[i]:=Chr(Ord(s[i])-4);
if Ord(s1[i])<Ord('a') then
s1[i]:=Chr(Ord(s1[i])+26);
end;
Result:=s1;
end;
begin
edit2.text:=edit2.text+copy(edit1.Text,i,1);
str:=copy(edit1.Text,i,1);//拆分字符串,有什么错误吗?
我的怎么运行不了,怪了