建立一個英文代號的對照表 :
short encode[] = {
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
};
接著再依照題目說明的規則即可。
程式碼:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
short encode[] = { | |
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 | |
}; | |
const short SIZE = 8; | |
char a; | |
int n; | |
while( cin >> a >> n) | |
{ | |
int temp = encode[a - 'A']; | |
int check = (temp % 10) * 9 + temp / 10; | |
check += (n % 10); | |
n = n / 10; | |
for(int i = 1; i <= SIZE; i++) | |
{ | |
check += (n % 10) * i; | |
n = n / 10; | |
} | |
if( check % 10 == 0 ) | |
cout << "real"; | |
else | |
cout << "fake"; | |
cout << endl; | |
} | |
return 0; | |
} |
沒有留言:
張貼留言