Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:38
Show Gist options
  • Save pinglunliao/c0fa26d56e762ee4c8cc to your computer and use it in GitHub Desktop.
Save pinglunliao/c0fa26d56e762ee4c8cc to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
void prtResult(int n)
{
switch(n) {
case 10:
cout << "BNZ" << endl;
break;
case 1:
cout << "AMW" << endl;
break;
case 2:
cout << "KLY" << endl;
break;
case 3:
cout << "JVX" << endl;
break;
case 4:
cout << "HU" << endl;
break;
case 5:
cout << "GT" << endl;
break;
case 6:
cout << "FS" << endl;
break;
case 7:
cout << "ER" << endl;
break;
case 8:
cout << "DOQ" << endl;
break;
case 9:
cout << "CIP" << endl;
break;
default:
cout << "Error" << endl;
break;
}
}
int main() {
string num;
while(cin >> num)
{
int sum = 0;
for(unsigned int i = 0; i < num.size() - 1; i++)
{
sum += (num[i] - '0') * (8-i);
}
sum += (num[num.size() - 1]-'0');
int tar = 10 - (sum % 10);
prtResult(tar);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment