#12816: 測試有過,送出執行是WA 請問該怎麼知道是哪筆測資沒過?


kagerou (一ノ瀬帆波)

學校 : 高雄市立中山高級中學
編號 : 69913
來源 : [1.160.56.134]
最後登入時間 :
2019-03-07 22:23:36
a020. 身分證檢驗 | From: [125.224.109.206] | 發表日期 : 2017-10-17 17:36

#include #include using namespace std; char cc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\0"; int ccc[]= {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}; map<char,int> m; class ID{ private: int region; int num[9]; public: ID(char reg, int* n){ region = m[reg]; for(int i = 0; i < 9; i++){ num[i] = n[i]; } } void verify(){ int step2 = (region/10) + (region%10)*9; int w = 9; for(int i = 0; i < 8; i++){ step2 += num[i] * w; w --; } step2 += num[8]; if(step2%10 == 0) cout << "real\n"; else cout << "fake\n"; } }; int main(){ string s; int number[9]; while(cin >> s){ //get first char = c char c = s.front(); //get number array = number[] string num = s.substr(1,9); for(int i = 0; i < 9; i++){ number[i] = num.at(i)-'0'; } //set map for(int i = 0; i < 26; i++){ char c1 = cc[i]; m[c1] = ccc[i]; } ID person(c,number); person.verify(); } return 0; }

 
ZeroJudge Forum