| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
水完今天最后一道明天接着来A题代码留在这作纪念
#include<iostream>
#include<Cstdio>
using namespace std;
char word[500];
int main()
{
int count, sum, cha, pos;
while(1)
{
cin.getline(word, 500);
//cout << word[0] << endl;
if(word[0] == '#')
break;
count = 0, sum = 0;
char *p = word;
while (*p != '\0')
{
if(*p >= 'A' && *p <= 'Z')
cha = *p - 'A' + 1;
else if(*p == ' ')
cha = 0;
pos = p - word + 1;
sum += pos * cha;
p ++;
}
cout << sum << endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator