#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<pair<char,int>>a(26);
a[1 ].first = 'A'; a[1 ].second = 10;
a[2 ].first = 'B'; a[2 ].second = 11;
a[3 ].first = 'C'; a[3 ].second = 12;
a[4 ].first = 'D'; a[4 ].second = 13;
a[5 ].first = 'E'; a[5 ].second = 14;
a[6 ].first = 'F'; a[6 ].second = 15;
a[7 ].first = 'G'; a[7 ].second = 16;
a[8 ].first = 'H'; a[8 ].second = 17;
a[9 ].first = 'I'; a[9 ].second = 34;
a[10].first = 'J'; a[10].second = 18;
a[11].first = 'K'; a[11].second = 19;
a[12].first = 'L'; a[12].second = 20;
a[13].first = 'M'; a[13].second = 21;
a[14].first = 'N'; a[14].second = 22;
a[15].first = 'O'; a[15].second = 35;
a[16].first = 'P'; a[16].second = 23;
a[17].first = 'Q'; a[17].second = 24;
a[18].first = 'R'; a[18].second = 25;
a[19].first = 'S'; a[19].second = 26;
a[20].first = 'T'; a[20].second = 27;
a[21].first = 'U'; a[21].second = 28;
a[22].first = 'V'; a[22].second = 29;
a[23].first = 'W'; a[23].second = 32;
a[24].first = 'X'; a[24].second = 30;
a[25].first = 'Y'; a[25].second = 31;
a[26].first = 'Z'; a[26].second = 33;
string s;
while(cin>>s){
int ans = 0;
for(int i=0;i<24;i++){
if(s[0]==a[i].first){
ans = ans + ((a[i].second%10)*9)+(a[i].second/10);
}
}
for(int i=1;i<9;i++){
ans = ans + (9-i)*(s[i]-'0');
}
ans = ans + (s[9]-'0');
cout <<"總合為 "<<ans;
if(ans%10==0){
cout << "real"<<endl;
}
else{
cout << "fake"<<endl;
}
}
#include
#include
using namespace std;
int main()
{
vector<pair<char,int>>a(26);
a[1 ].first = 'A'; a[1 ].second = 10;
a[2 ].first = 'B'; a[2 ].second = 11;
a[3 ].first = 'C'; a[3 ].second = 12;
a[4 ].first = 'D'; a[4 ].second = 13;
a[5 ].first = 'E'; a[5 ].second = 14;
a[6 ].first = 'F'; a[6 ].second = 15;
a[7 ].first = 'G'; a[7 ].second = 16;
a[8 ].first = 'H'; a[8 ].second = 17;
a[9 ].first = 'I'; a[9 ].second = 34;
a[10].first = 'J'; a[10].second = 18;
a[11].first = 'K'; a[11].second = 19;
a[12].first = 'L'; a[12].second = 20;
a[13].first = 'M'; a[13].second = 21;
a[14].first = 'N'; a[14].second = 22;
a[15].first = 'O'; a[15].second = 35;
a[16].first = 'P'; a[16].second = 23;
a[17].first = 'Q'; a[17].second = 24;
a[18].first = 'R'; a[18].second = 25;
a[19].first = 'S'; a[19].second = 26;
a[20].first = 'T'; a[20].second = 27;
a[21].first = 'U'; a[21].second = 28;
a[22].first = 'V'; a[22].second = 29;
a[23].first = 'W'; a[23].second = 32;
a[24].first = 'X'; a[24].second = 30;
a[25].first = 'Y'; a[25].second = 31;
a[26].first = 'Z'; a[26].second = 33;
string s;
while(cin>>s){
int ans = 0;
for(int i=0;i<24;i++){
if(s[0]==a[i].first){
ans = ans + ((a[i].second%10)*9)+(a[i].second/10);
}
}
for(int i=1;i<9;i++){
ans = ans + (9-i)*(s[i]-'0');
}
ans = ans + (s[9]-'0');
cout <<"總合為 "<<ans;
if(ans%10==0){
cout << "real"<<endl;
}
else{
cout << "fake"<<endl;
}
}
FOR 迴圈的條件是不是寫錯了?