poj3094

简单的字符串题

View Code
#include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
using namespace std;

int main()
{
//freopen("D:\\t.txt", "r", stdin);
string st;
while (getline(cin, st) && st != "#")
{
int sum = 0;
for (int i = 0; i < st.length(); i++)
if (st[i] != ' ')
sum
+= (i + 1) * (st[i] - 'A' + 1);
cout
<< sum << endl;
}
return 0;
}
posted @ 2011-03-13 12:03  金海峰  阅读(240)  评论(0编辑  收藏  举报