a020.
身分證檢驗
| From: [73.12.0.148] |
發表日期
:
2015-03-30 02:52
請大大過目
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
while(getline(cin,a))
{
int check=0;
switch (a[0])
{
case 'A': check = 1 + 0 * 9; break;
case 'B': check = 1 + 1 * 9; break;
case 'C': check = 1 + 2 * 9; break;
case 'D': check = 1 + 3 * 9; break;
case 'E': check = 1 + 4 * 9; break;
case 'F': check = 1 + 5 * 9; break;
case 'G': check = 1 + 6 * 9; break;
case 'H': check = 1 + 7 * 9; break;
case 'I': check = 3 + 4 * 9; break;
case 'J': check = 1 + 8 * 9; break;
case 'K': check = 1 + 9 * 9; break;
case 'L': check = 2 + 0 * 9; break;
case 'M': check = 2 + 1 * 9; break;
case 'N': check = 2 + 2 * 9; break;
case 'O': check = 3 + 5 * 9; break;
case 'P': check = 2 + 3 * 9; break;
case 'Q': check = 2 + 4 * 9; break;
case 'R': check = 2 + 5 * 9; break;
case 'S': check = 2 + 6 * 9; break;
case 'T': check = 2 + 7 * 9; break;
case 'U': check = 2 + 8 * 9; break;
case 'V': check = 2 + 9 * 9; break;
case 'W': check = 3 + 2 * 9; break;
case 'X': check = 3 + 0 * 9; break;
case 'Y': check = 3 + 1 * 9; break;
case 'Z': check = 3 + 3 * 9; break;
}
int i;
for(i=1;i<9;i++)
{
cout<< a[i]<<"*"<<(9-i)<<endl; // 這是檢查a[i] and (9-i)用的,測試時也很正常 like 1*8, 5*7
check+=((9-i)*a[i]); // 但這裡就見鬼了,每回都幾百幾百的加
}
check=check+a[9];
if (check%10==0)
{
cout<< "real"<<endl;
break;
}
else
{
cout<< "fake"<<endl;
break;
}
}
return 0;
}