#25000: C++求解


ssss671900 (1091507)

學校 : 元智大學
編號 : 147923
來源 : [61.70.0.90]
最後登入時間 :
2022-02-16 12:14:55
a020. 身分證檢驗 | From: [61.70.0.90] | 發表日期 : 2021-04-11 13:38

#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"; }

}

}

 

我一直想不到~請大家幫助我

 
#25001: Re:C++求解


ssss671900 (1091507)

學校 : 元智大學
編號 : 147923
來源 : [61.70.0.90]
最後登入時間 :
2022-02-16 12:14:55
a020. 身分證檢驗 | From: [61.70.0.90] | 發表日期 : 2021-04-11 14:13

#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了!

 
ZeroJudge Forum