單純查表
#include <iostream>
using namespace std;
int main()
{
char symbol[] = {'A', 'B', 'G', 'D', 'E', '#', 'Z', 'Y', 'H', 'I', 'K', 'L', 'M', 'N', 'X', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'F', 'C', '$', 'W', 0};
int number[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900};
char input[3];
int answer;
int i, j;
while(cin >> input && input[0] != '.'){
answer = 0;
for(i = 0; input[i]; i++){
for(j = 0; symbol[j] && input[i] != symbol[j]; j++);
answer += number[j];
}
cout << answer << endl;
}
return 0;
}
全站熱搜
留言列表