送分,改一个函数!(300分)

  • 主题发起人 主题发起人 chooy
  • 开始时间 开始时间
C

chooy

Unregistered / Unconfirmed
GUEST, unregistred user!
大家好,本人对DELPHI很爱好,但是水平很低。下面这段函数源码请前辈
改成一个单独的程序。第一个改完的,测试OK后可独得300分,谢谢!
要求是这样,在一个窗口上放三个控件。edit1、edit2、Button1。
在edit1中输入一串字符以后,点击Button1,会在edit2输出一个加密后
的字串。
谢谢大家!


==============================================================
function TfrmTZYMain.change(pwd: string):string;
var
s1,s2:String;
i,j:integer;
begin
s1:=trim(pwd);
s2:=s1;
j:=1;
for i:=1 to length(s1) do
if (i mod 2)=0 then
begin
if chr(ord(s1) xor 9) IN ['0'..'9','a'..'z','A'..'Z',':'] then
s2[j]:=chr(ord(s1) xor 9)
else
s2[j]:=s1;
inc(j);
end;
for i:=1 to length(s1) do
if (i mod 2)=1 then
begin
if chr(ord(s1) xor 9) IN ['0'..'9','a'..'z','A'..'Z',':'] then
s2[j]:=chr(ord(s1) xor 9)
else
s2[j]:=s1;
inc(j);
end;
result:=s2;
end;
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function change(pwd: string):string;
var
s1,s2:String;
i,j:integer;
begin
s1:=trim(pwd);
s2:=s1;
j:=1;
for i:=1 to length(s1) do
if (i mod 2)=0 then
begin
if chr(ord(s1) xor 9) IN ['0'..'9','a'..'z','A'..'Z',':'] then
s2[j]:=chr(ord(s1) xor 9)
else
s2[j]:=s1;
inc(j);
end;
for i:=1 to length(s1) do
if (i mod 2)=1 then
begin
if chr(ord(s1) xor 9) IN ['0'..'9','a'..'z','A'..'Z',':'] then
s2[j]:=chr(ord(s1) xor 9)
else
s2[j]:=s1;
inc(j);
end;
result:=s2;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text :=Change(Edit1.Text);
end;

end.
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function change(pwd: string):string;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.change(pwd: string):string;
var
s1,s2:String;
i,j:integer;
begin
s1:=trim(pwd);
s2:=s1;
j:=1;
for i:=1 to length(s1) do
if (i mod 2)=0 then
begin
if chr(ord(s1) xor 9) IN ['0'..'9','a'..'z','A'..'Z',':'] then
s2[j]:=chr(ord(s1) xor 9)
else
s2[j]:=s1;
inc(j);
end;
for i:=1 to length(s1) do
if (i mod 2)=1 then
begin
if chr(ord(s1) xor 9) IN ['0'..'9','a'..'z','A'..'Z',':'] then
s2[j]:=chr(ord(s1) xor 9)
else
s2[j]:=s1;
inc(j);
end;
result:=s2;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:=change(Edit1.Text);
end;

end.
 
谢谢netwinds! 等会验证通过后就给您加分,现在我要开个小会,等一下就过来!

 
也非常感谢forgot2002!!!!!!!
 

Similar threads

后退
顶部