function dwdmjym(dwdm:string;var ReChar:Char):Boolean;
const
Wi: array[1..8] of string = ('3','7','9','10','5','8','4','2');
ai: array[0..35] of string = ('0','1','2','3','4','5','6','7','8','9','A',
'B','C','D','E','F','G','H','I','J','K','L',
'M','N','O','P','Q','R','S','T','U','V','W',
'X','Y','Z');
bi: array[0..35] of string = ('0','1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20','21',
'22','23','24','25','26','27','28','29','30','31','32',
'33','34','35');
function GetAi(S:Char):string;
var I:integer;
begin
Result :='';
for I:=0 to 35 do
if S=ai[I] then
begin
Result :=bi[I];
Break;
end;
end;
var
J,Sum,ModResult:integer;
S:string;
begin
Result:=True;
Sum:=0;
for J:=1 to Length(dwdm) do
begin
S:=GetAi(dwdm[J]);
if S='' then
begin
Result :=False;
Break;
end;
Sum:=Sum+strtoint(S)*strtoint(Wi[J]);
end;
if not Result then Exit;
ModResult:=Sum mod 11;
if ModResult=1 then ReChar:='X'
else if ModResult=0 then ReChar:='0'
else begin
S :=inttostr(11-ModResult);
ReChar:=S[1];
end;
end;function dwdmjy(dwdm:string):Boolean;
var ReChar:Char;
begin
Result :=dwdmjym(Copy(dwdm,1,8),ReChar);
if Result then
if ReChar<>dwdm[9] then Result :=False;
end;
const
Wi: array[1..8] of string = ('3','7','9','10','5','8','4','2');
ai: array[0..35] of string = ('0','1','2','3','4','5','6','7','8','9','A',
'B','C','D','E','F','G','H','I','J','K','L',
'M','N','O','P','Q','R','S','T','U','V','W',
'X','Y','Z');
bi: array[0..35] of string = ('0','1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20','21',
'22','23','24','25','26','27','28','29','30','31','32',
'33','34','35');
function GetAi(S:Char):string;
var I:integer;
begin
Result :='';
for I:=0 to 35 do
if S=ai[I] then
begin
Result :=bi[I];
Break;
end;
end;
var
J,Sum,ModResult:integer;
S:string;
begin
Result:=True;
Sum:=0;
for J:=1 to Length(dwdm) do
begin
S:=GetAi(dwdm[J]);
if S='' then
begin
Result :=False;
Break;
end;
Sum:=Sum+strtoint(S)*strtoint(Wi[J]);
end;
if not Result then Exit;
ModResult:=Sum mod 11;
if ModResult=1 then ReChar:='X'
else if ModResult=0 then ReChar:='0'
else begin
S :=inttostr(11-ModResult);
ReChar:=S[1];
end;
end;function dwdmjy(dwdm:string):Boolean;
var ReChar:Char;
begin
Result :=dwdmjym(Copy(dwdm,1,8),ReChar);
if Result then
if ReChar<>dwdm[9] then Result :=False;
end;
解决方案 »
- windows2003 终端服务 登录的时候,有办法自动启动某程序吗?
- 请问Delphi 2007 有没有MAC OS 风格的界面控件?
- 在AdoQuery和sql数据库表中,咋样实现记录的定位?(就是运行完后,鼠标点在表的哪一行,记录就定位在该行?)
- 在Dll工程中引用fastreport控件的怪问题。
- 如何判断一个数能否被另一个数整除???????????????????
- 用QUERY查找时,没有找到结果。要怎么样才会有提示信息出现?
- ghao0(干什么) 来领分,欠债还钱,天经地义
- 能把ODBC配置也用Installshield打包吗?
- 怎样让report形式的listview能够分页显示?
- Delphi中如何在两个EXE的应用程序中传递数据?
- 看看这个图片转换函数,为什么bmp转jpg时正常,jpg转jpg时,转成的图片Delphi自己不认识.
- 请教一个指针函数的问题?
final String ai[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
"B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
"M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z"};
final String bi[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21",
"22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32",
"33", "34", "35"};
String GetAi(char S)
{
int i;
for(i=0;i<=35;i++)
{
if(S==ai[i].charAt(0))
{
break;
}
}
return bi[i];
}
Boolean dwdmjym(String dwdm, char ReChar)
{
int j,Sum,ModResult;
String S;
Boolean vbool;
Sum = 0;
vbool = Boolean.TRUE;
for(j=1;j<=dwdm.length();j++)
{
S = GetAi(dwdm.charAt(0));
if(S=="")
{
vbool = Boolean.FALSE;
break;
}
Sum = Sum + Integer.parseInt(S)*Integer.parseInt(Wi[j]);
}
if(vbool==Boolean.FALSE) return vbool;
ModResult = Sum%11;
if(ModResult==1)
{
ReChar = 'X';
}else if(ModResult==0)
{
ReChar = ' ';
}else
{
ModResult = 11-ModResult;
S = Integer.toString(ModResult);
ReChar = S.charAt(1);
}
return vbool;
}
Boolean dwdmjy(String dwdm)
{
char ReChar;
Boolean vbool;
ReChar = 'B';
vbool = dwdmjym(dwdm.substring(0,8),ReChar);
if (vbool==Boolean.TRUE)
{
if (ReChar!=dwdm.charAt(8))
{
vbool = Boolean.FALSE;
}
}
return vbool;
}