求助Delphi 写一个字节翻转
输入框如 输入1234567890输出框转换出 2143658709
求高手帮忙写一个或者提供源码也行
先谢谢了 留个名,下午补代码~ //假设有edit1,labei1两个控件,大概就是这样吧,delphi很久没用了,好多都忘了,凑合凑合啊,有问题留言
var
str,temp:String;
i:Integer;
begin
str :=edit1.text;
i :=0;
for i to Length(str)-1 do
begin
if(i mod 2 == 1)
temp :=str;
str:=str;
str:=str;
end;
label1.caption :=str;
end;
你的“1234567890”是16进制的还是10进制的?如果是10进制的照你那样写就不是单字节翻转,而是相邻两字节翻转
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
btn1: TBitBtn;
edt1: TEdit;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var dj:Integer=0;
{$R *.dfm}
procedure dh (var i:string);
begin
asm
mov ebx,0
mov ecx,0ffffh
mov ebx,i
mov esi,
@s:mov al,
cmp al,0
je @ok
xchg al,
mov 1,al
add esi,2
loop @s
@ok:nop
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
s:string;
i:byte;
begin
s:=Trim(edt1.Text);
dh(s);
edt1.Text:=s;
end;
end.
D里使用的汇编~嘿嘿
页:
[1]