心如止水
Je n'ai pas le temps
posts - 400,comments - 130,trackbacks - 0
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 阅读(123) 评论(0)  编辑 收藏 引用 所属分类: 题目分类:字符串处理

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理