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.
22 lines
501 B
22 lines
501 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
const int N = 26;
|
|
//常数字典
|
|
int b[N] = {1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4};
|
|
int cnt;
|
|
string s;
|
|
|
|
int main() {
|
|
//输入
|
|
getline(cin, s);
|
|
//遍历每一个
|
|
for (int i = 0; i < s.size(); i++) {
|
|
if (s[i] >= 'a' && s[i] <= 'z')
|
|
cnt += b[s[i] - 'a'];//计数思路增加个数
|
|
if (s[i] == ' ') cnt++;
|
|
}
|
|
cout << cnt << endl;
|
|
return 0;
|
|
} |