简单的字符串题
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;
}