又一道字符串的水题....
#include <iostream> #include <cstring> using namespace std; int main() { char ch[260]; while(cin.getline(ch,260)) { if(ch[0] == '#') break; int ans = 0; int n = strlen(ch); for(int i=0;i < n;++i) { if(ch[i] >= 'A' && ch[i] <= 'Z') ans += (ch[i] - 'A' + 1)*(i + 1); } cout<<ans<<endl; } return 0; }