#12045: C++ 參考解答


shawn2000100 (東華財金)

學校 : 國立東華大學
編號 : 57300
來源 : [27.53.168.5]
最後登入時間 :
2021-09-19 19:53:19
a020. 身分證檢驗 | From: [134.208.255.201] | 發表日期 : 2017-05-19 22:51

#include<iostream>
using namespace std;

int main()
{
string input;
int city[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
};
while ( cin >> input ) {
int sum = 0, head = city[input[0] - 'A'];
sum += ( ( head / 10 ) + ( head % 10 ) * 9 );
for ( int i = 8, j = 1; i >= 1; i--, j++ )
sum += ( input[j] - '0' ) * i;
sum += ( input[9] - '0' );
if ( sum % 10 == 0 )
cout << "real" << endl;
else
cout << "fake" << endl;
}
return 0;
}

 
ZeroJudge Forum