a020.
身分證檢驗
| From: [125.228.237.153] |
發表日期
:
2012-02-14 00:40
#include<iostream>
int number(char n)
{
int a = 0,b = 0,c = -1,d = 0;
if(n=='A'||n=='B'||n=='C'||n=='D'||n=='E'||n=='F'||n=='G'||n=='H'||n=='W')
{a = n-55;d = 1;}
if(n=='J'||n=='K'||n=='L'||n=='M'||n=='N')
{a = n-56;d = 1;}
if(n=='P'||n=='Q'||n=='R'||n=='S'||n=='T'||n=='U'||n=='V'||n=='Z')
{a = n-57;d = 1;}
if(n=='O')
{a = n-44;d = 1;}
if(n=='I')
{a = n-39;d = 1;}
if(n=='X'||n=='Y')
{a = n-58;d = 1;}
b=(a%10)*9;
a/=10;
if(d==1)
{
c=a+b;
return c;
}
if(d==0)
{
std::cout<<"fake"<<std::endl;
return c;
}
}
void C(int head,char ID[11],int d = 0)
{
for(int i=1,j=8;i<9,j>0;i++,j--)
d+=(ID[i]-48)*j;
d+=(ID[9]-48)+head;
if(d%10==0&&head!=-1)
std::cout<<"real"<<std::endl;
if(d%10!=0&&head!=-1)
std::cout<<"fake"<<std::endl;
}
int main()
{
char ID1[11]={0},ID2[11]={0};
while(std::cin>>ID1>>ID2);
{
C(number(ID1[0]),ID1);
C(number(ID2[0]),ID2);
}
}
請高手看一下 為甚麼line2?