身份证末位验证码!
#include<iostream>
using namespace std;
main()
{
char Ai[17],*p,xn[11]={'1','0','X','9','8','7','6','5','4','3','2'};
int wi[]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
int Aiwi[18],num[18];
int le,i,sum=0;
cout<<"请输入17位身份证号码:";//除个位或15位的从第七位起插入19;
cin>>Ai;
cout<<"新的身份证号码:";
p=Ai;
le=strlen(Ai);
for(i=0;i<le;i++)
{
num[i]=*(p+i)-'0';
Aiwi[i]=num[i]*wi[i];
sum+=Aiwi[i];
cout<<' '<<num[i];
}
cout<<' '<<xn[sum%11];
}
[此贴子已经被作者于2007-9-16 19:37:12编辑过]