1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> using namespace std; int main() { int num[26] = { 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10 }; int sum = 0; string S; cin >> S; for (int i = 0; i < S.length(); ++i) { int index = S[i] – 65; sum += num[index]; } cout << sum << endl; return 0; } | cs |