Here is my code:
#include<iostream>
#include<string>
using namespace std;
const int r[]={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()
{
string s;
long len,ans;
getline(cin,s);
len=s.length();
ans=0;
for(long i=0;i<len;i++)
if(s.at(i)>='a'&&s.at(i)<='z')
ans+=r[s.at(i)-'a'];
else ans+=1;
cout<<ans<<endl;
return 0;
}
posted on 2010-10-11 22:27
lee1r 阅读(134)
评论(0) 编辑 收藏 引用 所属分类:
题目分类:字符串处理