a换算完了是']',能不能限制在a……z

解决方案 »

  1.   

    Ch:=Chr(Ord('a')-4);
    if Ord(Ch)<65 then
      Ch:=Chr(Ord(Ch)+26);
      

  2.   

    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;
      

  3.   

    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;
      

  4.   

    上述有误,改为以下
    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;
      

  5.   

    for i:=1 to length (edit1.Text)do
    begin
    edit2.text:=edit2.text+copy(edit1.Text,i,1);
    str:=copy(edit1.Text,i,1);//拆分字符串,有什么错误吗?
    我的怎么运行不了,怪了