| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 875 人关注过本帖
标题:为什么不能正确得到余数
只看楼主 加入收藏
hn梅子
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-7-29
收藏
 问题点数:0 回复次数:2 
为什么不能正确得到余数


初学请大家帮助,下面的代码只有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.

搜索更多相关主题的帖子: 余数 
2006-07-29 15:32
hn梅子
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-7-29
收藏
得分:0 

已解决,原来要将前面用数值用()括起来,如:

b10:=(strtoint(a10)*strtoint(a10)+12) mod 10 ;

2006-07-29 17:20
volte
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:69
帖 子:1167
专家分:1316
注 册:2004-12-19
收藏
得分:0 
不能粗心啊,

不是技术的问题

大家都是朋友,有空就来坐坐!
2006-07-29 20:19
快速回复:为什么不能正确得到余数
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020228 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved