#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string s;
while (getline(cin, s))
{
int t = 0;
if (s[0] == 'A')
{
t = 1+(0*9);
}
if (s[0] == 'B')
{
t = 1 + (1 * 9);
}
if (s[0] == 'C')
{
t = 1 + (2 * 9);
}
if (s[0] == 'D')
{
t = 1 + (3 * 9);
}
if (s[0] == 'E')
{
t = 1 + (4 * 9);
}if (s[0] == 'F')
{
t = 1 + (5 * 9);
}
if (s[0] == 'G')
{
t = 1 + (6 * 9);
}
if (s[0] == 'H')
{
t = 1 + (7 * 9);
}
if (s[0] == 'I')
{
t = 3 + (4 * 9);
}
if (s[0] == 'J')
{
t = 1 + (8 * 9);
}
if (s[0] == 'K')
{
t = 1 + (9 * 9);
}
if (s[0] == 'L')
{
t = 2 + (0 * 9);
}
if (s[0] == 'M')
{
t = 2 + (1 * 9);
}
if (s[0] == 'N')
{
t = 2 + (2 * 9);
}
if (s[0] == 'O')
{
t = 3 + (5 * 9);
}
if (s[0] == 'P')
{
t = 2 + (3 * 9);
}
if (s[0] == 'Q')
{
t = 2 + (4 * 9);
}
if (s[0] == 'R')
{
t = 2 + (5 * 9);
}
if (s[0] == 'S')
{
t = 2 + (6 * 9);
}
if (s[0] == 'T')
{
t = 2 + (7 * 9);
}
if (s[0] == 'U')
{
t = 2 + (8 * 9);
}
if (s[0] == 'V')
{
t = 2 + (9 * 9);
}
if (s[0] == 'W')
{
t = 3 + (2 * 9);
}
if (s[0] == 'X')
{
t = 3 + (0 * 9);
}
if (s[0] == 'Y')
{
t = 3 + (1 * 9);
}
if (s[0] == 'Z')
{
t = 3 + (3 * 9);
}
for (int i = 1; i <= 8; i++)
{
{
t += s[i] * (9 - i);
}
}
t += s[9];
if (t % 10 == 0) { cout << "real"; }
else { cout << "fake"; }
}
}
我一直想不到~請大家幫助我
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
char s[10];
for(int i=0;i<10;i++)
{
cin >> s[i];
}
int t = 0;
int g = 0;
int b;
if (s[0] == 'A')
{
t = 1 + (0 * 9);
}
if (s[0] == 'B')
{
t = 1 + (1 * 9);
}
if (s[0] == 'C')
{
t = 1 + (2 * 9);
}
if (s[0] == 'D')
{
t = 1 + (3 * 9);
}
if (s[0] == 'E')
{
t = 1 + (4 * 9);
}if (s[0] == 'F')
{
t = 1 + (5 * 9);
}
if (s[0] == 'G')
{
t = 1 + (6 * 9);
}
if (s[0] == 'H')
{
t = 1 + (7 * 9);
}
if (s[0] == 'I')
{
t = 3 + (4 * 9);
}
if (s[0] == 'J')
{
t = 1 + (8 * 9);
}
if (s[0] == 'K')
{
t = 1 + (9 * 9);
}
if (s[0] == 'L')
{
t = 2 + (0 * 9);
}
if (s[0] == 'M')
{
t = 2 + (1 * 9);
}
if (s[0] == 'N')
{
t = 2 + (2 * 9);
}
if (s[0] == 'O')
{
t = 3 + (5 * 9);
}
if (s[0] == 'P')
{
t = 2 + (3 * 9);
}
if (s[0] == 'Q')
{
t = 2 + (4 * 9);
}
if (s[0] == 'R')
{
t = 2 + (5 * 9);
}
if (s[0] == 'S')
{
t = 2 + (6 * 9);
}
if (s[0] == 'T')
{
t = 2 + (7 * 9);
}
if (s[0] == 'U')
{
t = 2 + (8 * 9);
}
if (s[0] == 'V')
{
t = 2 + (9 * 9);
}
if (s[0] == 'W')
{
t = 3 + (2 * 9);
}
if (s[0] == 'X')
{
t = 3 + (0 * 9);
}
if (s[0] == 'Y')
{
t = 3 + (1 * 9);
}
if (s[0] == 'Z')
{
t = 3 + (3 * 9);
}
for(int l=1;l<9;l++)
{
g = (s[l] * 1)-48;
t += g * (9 - l);
}
b = s[9] - 48;
t += b;
if (t % 10 == 0) { cout << "real"; }
else { cout << "fake"; }
}
醬就OK了!