给定一个ISBN文件,要求提取其中的‘-’,删除不规则的ISBN码,如何操作啊!
求大哥大姐!
求大哥大姐!
解决方案 »
- 请问delphi中treeview怎么用呀。
- 高分求解:dll问题!?
- 三问小函数,送分
- 救命呀!俺笨,请各位江湖好汉多多相助!关于ftp端口的问题!
- 热心的DELPHI人来帮一下我这个初学者,指点一下明路。
- 用ADOConnection的GetTableNames方法的问题?
- 如何列出显卡、主板、声卡、USB设备的类型、编号、状态?
- 最高分请教,怎样让树状视图每一项都出现 hint 提示?
- 哪里能找到delphi自带例程的详细说明
- 程序作好后,并用IS生成安装文件后,请问如何将这些文件打包,然后再安装。是不是有什么工具。谢谢
- 高手,教科啊小弟错在哪儿
- 有关双摄像头的编程问题,急... ,在线等待
function IsISBN(ISBN: String): Boolean;
var
Number, CheckDigit: String;
CheckValue, CheckSum, Err: Integer;
i, Cnt: Word;
begin
{取得检验数字}
CheckDigit := Copy(ISBN, Length(ISBN), 1);
{Get rest of ISBN, minus check digit and its hyphen}
Number := Copy(ISBN, 1, Length(ISBN) - 2);{ISBN长度必须为11,并且组成数字必须介于9和9或X}
if (Length(Number) = 11) and (Pos(CheckDigit, '0123456789X') > 0) then
begin
{Get numeric value for check digit}
if (CheckDigit = 'X') then
CheckSum := 10
else
Val(CheckDigit, CheckSum, Err);
{Iterate through ISBN remainder, applying decode algorithm}
Cnt := 1;for i := 1 to 12 do begin
{如果当前字符介于0~9,则不包含连字符}
if (Pos(Number[i], '0123456789') > 0) then begin
Val(Number[i], CheckValue, Err);
{Algorithm for each character in ISBN remainder, Cnt is the nth
character so processed}
CheckSum := CheckSum + CheckValue * (11 - Cnt);
Inc(Cnt);
end;
end;{校验最后的值能否被11整除}
if (CheckSum MOD 11 = 0) then
IsISBN := True
else
IsISBN := False;
end
else
IsISBN := False;
end;