初学请大家帮助,下面的代码只有B0可以正常取得余数,其它的都不能得到余数,不知为什么?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
st1,st2,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15:string;
b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15:Integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Text:='7522663824377223';
st1:=edit1.Text;
a0:=copy(st1,15,1);
b0:=strtoint(a0)*strtoint(a0)+14 mod 10;
a1:=copy(st1,10,1);
b1:=strtoint(a1)*strtoint(a1)+7 mod 10;
a2:=copy(st1,1,1);
b2:=strtoint(a2)*strtoint(a2)+9 mod 10 ;
a3:=copy(st1,11,1);
b3:=strtoint(a3)*strtoint(a3)+16 mod 10 ;
a4:=copy(st1,9,1);
b4:=strtoint(a4)*strtoint(a4)+15 mod 10 ;
a5:=copy(st1,3,1);
b5:=strtoint(a5)*strtoint(a5)+10 mod 10 ;
a6:=copy(st1,2,1);
b6:=strtoint(a6)*strtoint(a6)+3 mod 10 ;
a7:=copy(st1,14,1);
b7:=strtoint(a7)*strtoint(a7)+13 mod 10 ;
a8:=copy(st1,8,1);
b8:=strtoint(a8)*strtoint(a8)+2 mod 10 ;
a9:=copy(st1,4,1);
b9:=strtoint(a9)*strtoint(a9)+1 mod 10 ;
a10:=copy(st1,12,1);
b10:=strtoint(a10)*strtoint(a10)+12 mod 10 ;
a11:=copy(st1,7,1);
b11:=strtoint(a11)*strtoint(a11)+8 mod 10 ;
a12:=copy(st1,6,1);
b12:=strtoint(a12)*strtoint(a12)+4 mod 10 ;
a13:=copy(st1,13,1);
b13:=strtoint(a13)*strtoint(a13)+5 mod 10 ;
a14:=copy(st1,16,1);
b14:=strtoint(a14)*strtoint(a14)+6 mod 10 ;
a15:=copy(st1,5,1);
b15:=strtoint(a15)*strtoint(a15)+11 mod 10 ;
edit2.Text:=inttostr(b0)+inttostr(b1);
end;
end.