身份证号尾数计算器

Update: 此程序的在线版在 https://blog.cxqn.info/archives/1053

之前应别人要求用Pascal写的小程序,现在干脆开源了吧。
本程序基于开源协议WTFPL发布。

program sfz;
{
          DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                  Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.

}
const
a:array[1..18] of integer=(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
ass:array[0..10] of char=('1','','x','9','8','7','6','5','4','3','2'); 

var i,t,j,as:integer;
c:char;
cc:array[1..17] of char; 

begin
writeln('身份证号解算 v0.0');
writeln;
writeln('请输入身份证号(前17位):'); writeln;
as:=0;
for i:=1 to 17 do begin
read(c);cc[i]:=c;
t:=ord(c)-48;
inc(as,a[i]*t);
end; 

//writeln;
as:=as mod 11;
//writeln(as mod 11);
writeln;
writeln('完整有效的身份证号是:'); writeln;
for i:=1 to 17 do write(cc[i]);
writeln(ass[as]);
writeln;writeln;writeln;writeln(
'This program is written by @chenxiaoqino, thanks for using.');
readln;readln;
end.

Code highlighted by GeSHi.
0.016/0.054/0.001 seconds (language loading/parsing/cleanup)

3 Responses to “身份证号尾数计算器”


发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Powered by WordPress. Design: Supermodne.