poj3094 string模拟

2019-11-29  本文已影响0人  暖昼氤氲
 /*
Time:2019.11.29
Author: Goven
type:string模拟 
err:
ref:
*/
#include<iostream>
#include<string>
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;
}

上一篇下一篇

猜你喜欢

热点阅读