//1_5_3: Quicksum 求字符串的校验 POJ3094 ZOJ2812
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int i,sum;
char str[260];
while(gets(str),str[0] != '#')
{
i = sum = 0;
while(str[i])
{
if(str[i] == ' ') i++;
else
{
sum += (i + 1) * (int)(str[i] - 'A' + 1);
i++;
}
}
printf("%d\n",sum);
}
return 0;
}
/*测试结果:通过POJ3094 ZOJ2812检测
ACM
46
MID CENTRAL
650
REGIONAL PROGRAMMING CONTEST
4690
ACN
49
A C M
75
ABC
14
BBC
15
#
请按任意键继续. . .
*/
POJ3094 ZOJ2812 Quicksum
最新推荐文章于 2018-12-18 18:32:53 发布