TOJ 3758: The value of poetry

来源:互联网 发布:知乎回答排名规则 编辑:程序博客网 时间:2024/06/05 21:55

3758: The value of poetry

描述

"When I was down beside the sea,

 A wooden spade they gave to me

 To dig the sandy shore

 The holes were empty like a cup ... "

 

Bob is a little boy who began to study english. Every day, his teacher will guide them read one or more poetries loudly though they don't  understand the meaning of the poetries. But it seems that it doesn't affect Bob enthusiasm of learning english. Because he has his own standard to evaluate a poetry. A letter's order in alphabet is his value no matter lowercase or uppercase and punctuations, digits and spaces' value will be ignored.

 Now, can you calculate the value of the poetry after Bob read it over?

 

输入

The input contains multiple test cases.(No more than 100)

Each case contains a poetry only with letters, spaces and punctuations.

The length of the poetry will not bigger than 10000.

输出

You should output one line with the value of poetry Bob read.

 

样例输入

HDOJ
A C M
"acm"

样例输出

37
17
17

代码

#include <stdio.h>
#include <string.h>
int main()
{
char s[10001];
int i,l,a;
while(gets(s)&&s[0]!='\0')
{
a=0;
l=strlen(s);
for(i=0;i<l;i++)
{
if(s[i]>='a'&&s[i]<='z')
a=a+s[i]-96;
if(s[i]>='A'&&s[i]<='Z')
a=a+s[i]-64;
}
printf("%d\n",a);
}
return 0;

原创粉丝点击