a020.
身分證檢驗
| From: [182.155.248.212] |
發表日期
:
2015-07-28 15:35
#include <iostream>
#include <string>
using namespace std;
int main()
{
string inputStr;
int engArr[26] = { 10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33 };
int engTitleNumber;
int numTotal = 0;
int sum = 0;
while (getline(cin, inputStr))
{
//英文轉換成數值
engTitleNumber = engArr[inputStr[0] - 'A'] / 10 + engArr[inputStr[0] - 'A'] % 10 * 9;
for (int i = 1; i < 9; i++) //數字轉換成數值
{
numTotal = ( ( int )inputStr[i] ) * (9 - i);
}
numTotal += (int)inputStr[9] ; //最後一個數字
sum = numTotal + engTitleNumber;
//cout << sum << endl;
if (sum % 10 == 0)
cout << "real" << endl;
else
cout << "fake" << endl;
}
system("PAUSE");
return 0;
}