You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
917 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); //读入输出优化的强迫症
map<char, int> _map;//表示以char类型为下标存储的是int
_map['a'] = 1;
_map['b'] = 2;
_map['c'] = 3;
_map['d'] = 1;
_map['e'] = 2;
_map['f'] = 3;
_map['g'] = 1;
_map['h'] = 2;
_map['i'] = 3;
_map['j'] = 1;
_map['k'] = 2;
_map['l'] = 3;
_map['m'] = 1;
_map['n'] = 2;
_map['o'] = 3;
_map['p'] = 1;
_map['q'] = 2;
_map['r'] = 3;
_map['s'] = 4;
_map['t'] = 1;
_map['u'] = 2;
_map['v'] = 3;
_map['w'] = 1;
_map['x'] = 2;
_map['y'] = 3;
_map['z'] = 4;
_map[' '] = 1;
string str = "";
//输入一个字符串
getline(cin, str);
int l = 0;
for (int i = 0; i < str.length(); i++) {
l += _map[str[i]];
}
cout << l << endl;
return 0;
}