TOJ 3758: The value of poetry

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;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章