poj3094 string模拟

 /*
Time:2019.11.29
Author: Goven
type:string模拟 
err:
ref:
*/
#include
#include
using namespace std;

int main()
{
    string s;
    int l, quickSum;
    while (getline(cin, s) && s != "#") {
        l = s.length();
        quickSum = 0;
        for (int i = 0; i < l; i++) {
            if (s[i] == ' ') continue;
            quickSum += (s[i] - 'A' + 1) * (i + 1);
        }
        cout << quickSum << endl;
    } 
    return 0;
}

你可能感兴趣的:(poj3094 string模拟)