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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值