#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char** argv) {
string card,one,s1,s2,s3,s4,s5,s6,s7,s8,s9;
int s0,sum,sum1,sum2,sum3,sum4,sum5,sum6,sum7,sum8,sum9;
cin >> card;
one = card[0];
s1 = card[1]; s2 = card[2]; s3 = card[3]; s4 = card[4]; s5 = card[5]; s6 = card[6]; s7 = card[7]; s8 = card[8]; s9 = card[9];
sum1 = atoi(s1.c_str()); sum2 = atoi(s2.c_str());sum3 = atoi(s3.c_str());sum4 = atoi(s4.c_str());sum5 = atoi(s5.c_str());sum6 = atoi(s6.c_str());sum7 = atoi(s7.c_str());sum8 = atoi(s8.c_str());sum9 = atoi(s9.c_str());
sum = sum1 * 8 + sum2 * 7 + sum3 * 6 + sum4 * 5 + sum5 * 4 + sum6 * 3 + sum7 * 2 + sum8 * 1 + sum9;
if(one == "A"){s0 = (0*9)+1;}
else if (one == "B"){s0 = (1*9)+1;}
else if (one == "C"){s0 = (2*9)+1;}
else if (one == "D"){s0 = (3*9)+1;}
else if (one == "E"){s0 = (4*9)+1;}
else if (one == "F"){s0 = (5*9)+1;}
else if (one == "G"){s0 = (6*9)+1;}
else if (one == "H"){s0 = (7*9)+1;}
else if (one == "I"){s0 = (4*9)+3;}
else if (one == "J"){s0 = (8*9)+1;}
else if (one == "K"){s0 = (9*9)+1;}
else if (one == "L"){s0 = (0*9)+2;}
else if (one == "M"){s0 = (1*9)+2;}
else if (one == "N"){s0 = (2*9)+2;}
else if (one == "O"){s0 = (5*9)+3;}
else if (one == "P"){s0 = (3*9)+2;}
else if (one == "Q"){s0 = (4*9)+2;}
else if (one == "R"){s0 = (5*9)+2;}
else if (one == "S"){s0 = (6*9)+2;}
else if (one == "T"){s0 = (7*9)+2;}
else if (one == "U"){s0 = (8*9)+2;}
else if (one == "V"){s0 = (9*9)+2;}
else if (one == "W"){s0 = (2*9)+3;}
else if (one == "X"){s0 = (0*9)+3;}
else if (one == "Y"){s0 = (1*9)+3;}
else if (one == "Z"){s0 = (3*9)+3;}
s0 = s0 / 1 % 10;
sum = sum / 1 % 10;
sum = sum + s0;
if(sum % 10 == 0){
cout << "real\n";
}
else{
cout << "fake\n";
}
}
可以先開一個陣列用來存字母對數字的表 int y[] = {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 k = y[x[0] - 'A'];