# 求！C！+！+！解！法！

@洛谷亿岁 2019-04-29 19:01 回复 举报
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int ans=0;
string a;
getline(cin,a);
for(int i=0;i<a.size();i++)
{
if(a[i]=='a'||a[i]=='d'||a[i]=='g'||a[i]=='j'||a[i]=='m'||a[i]=='p'||a[i]=='t'||a[i]=='w') ans++;
if(a[i]=='b'||a[i]=='e'||a[i]=='h'||a[i]=='k'||a[i]=='n'||a[i]=='q'||a[i]=='u'||a[i]=='x') ans+=2;
if(a[i]=='c'||a[i]=='f'||a[i]=='i'||a[i]=='l'||a[i]=='o'||a[i]=='r'||a[i]=='v'||a[i]=='y') ans+=3;
if(a[i]=='s'||a[i]=='z') ans+=4;
if(a[i]==' ') ans++;
}
cout<<ans;
return 0;
}
@爸爸最帅了 2019-04-29 19:04 回复 举报

#include<bits/stdc++.h>
using namespace std;
int main()

@梁宸铭123 2019-04-29 19:08 回复 举报
#include<iostream>
#include<cstring>
using namespace std;
int zh(char c)//将字母转换为数字
{
return c-'a'+1;
}
const int cs[27]={0,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 main()
{
int ans;
char str[210];
gets(str);
int len=strlen(str);
for(int i=0;i<len;i++)
{

if(str[i]==' ')ans+=1;
else
ans+=cs[zh(str[i])];
}
cout<<ans;
return 0;
}