function Chang(s: string): string;
var
i,n,m: byte;
a: array of byte;
s1: string;
begin
s1:='';
n:=length(s);
getmem(a,n);
for i:=1 to n do
a[i]:=Integr(s[i]);
if (n mod 2)=0 then
begin
m:=n div 2;
for i:=1 to (n div 2) do
a[i]:=a[i]+a[i+2];
end
else
begin
m:=(n div 2)+1;
for i:=1 to (n div 2)+1 do
begin
if i<=(n div 2) then
a[i]:=a[i]+a[i+2]
else
a[i]:=a[i];
end;
end;
for i:=1 to m do
s1:=s1+String(a[i]);
result:=s1;
end;
Function JoinString(strInput:string):string;
var
strSource,strDes:string;
int1,int2,int3,int4:integer;
arrDes:array of string;
i,j,k,x:integer;
begin
strSource:=strInput;
i:=0;j:=0;k:=0;x:=0;
int1:=0;int2:=0;int3:=0;int4:=0;
i:=length(strSource);
if i mod 4=0 then begin
for k:=0 to (i div 4)-1 do begin
int1:=strtoint(strSource[k*4+1]);
int2:=strtoint(strSource[k*4+2]);
int3:=strtoint(strSource[k*4+3]);
int4:=strtoint(strSource[k*4+4]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
end
else begin
j:=i mod 4;
for k:=0 to (i div 4)-1 do begin
int1:=strtoint(strSource[k*4+1]);
int2:=strtoint(strSource[k*4+2]);
int3:=strtoint(strSource[k*4+3]);
int4:=strtoint(strSource[k*4+4]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
int1:=0;int2:=0;int3:=0;int4:=0;
x:=k*4+1;
if (x)<=i then
int1:=strtoint(strSource[x]);
if (x+1)<=i then
int2:=strtoint(strSource[x+1]);
if (x+2)<=i then
int3:=strtoint(strSource[x+2]);
if (x+3)<=i then
int4:=strtoint(strSource[x+3]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
Result:=strDes;
end;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
strSource,strDes:string;
int1,int2,int3,int4:integer;
arrDes:array of string;
i,j,k,x:integer;
begin
strSource:=memo1.Text;
i:=0;j:=0;k:=0;x:=0;
int1:=0;int2:=0;int3:=0;int4:=0;
i:=length(strSource);
if i mod 4=0 then begin
for k:=0 to (i div 4)-1 do begin
int1:=strtoint(strSource[k*4+1]);
int2:=strtoint(strSource[k*4+2]);
int3:=strtoint(strSource[k*4+3]);
int4:=strtoint(strSource[k*4+4]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
end
else begin
j:=i mod 4;
for k:=0 to (i div 4)-1 do begin
int1:=strtoint(strSource[k*4+1]);
int2:=strtoint(strSource[k*4+2]);
int3:=strtoint(strSource[k*4+3]);
int4:=strtoint(strSource[k*4+4]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
int1:=0;int2:=0;int3:=0;int4:=0;
x:=k*4+1;
if (x)<=i then
int1:=strtoint(strSource[x]);
if (x+1)<=i then
int2:=strtoint(strSource[x+1]);
if (x+2)<=i then
int3:=strtoint(strSource[x+2]);
if (x+3)<=i then
int4:=strtoint(strSource[x+3]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
memo2.Lines.Add(strDes);
end;