#29552: C++紀錄


e3524167 (Kenlogin)

學校 : 不指定學校
編號 : 186743
來源 : [182.233.207.92]
最後登入時間 :
2022-03-17 21:12:56
a020. 身分證檢驗 | From: [182.233.207.92] | 發表日期 : 2022-03-11 19:32

#include <iostream>

#include <string> 

#include <sstream>

using namespace std;

int main()

{

string x;

string y[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"};

stringstream temp;

stringstream temp2;

int res=0;

while ( cin >> x ) 

{

int n = (int)(x[0]-65);

x.insert(0, y[n]);

x.erase(2, 1);

 

for (int i = 1; i<x.length()-1; i++)

{

int a;

temp << x[i];

temp >> a;

res = res + (a * (10 - i));

 

temp.str("");

temp.clear();

}

int a,b;

temp << x[0];

temp >> a;

temp2 << x[x.length()-1];

temp2 >> b;

res = res + a + b;

temp.str("");

temp.clear();

temp2.str("");

temp2.clear();

 

if (res % 10 == 0)

{

cout << "real" << endl;

}

else

{

cout << "fake" << endl;

}

}

}

 
ZeroJudge Forum