POJ3094 - Quicksum
1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 int main() 6 { 7 string input; 8 while (getline(cin, input)) 9 { 10 int Quicksum = 0; 11 if (input == "#") 12 return 0; 13 for (int i = 0; i < input.size(); i++) 14 { 15 if (input[i] == ' ') 16 Quicksum += (input[i]-32)*(i+1); 17 else 18 { 19 Quicksum += (input[i]-64)*(i+1); 20 } 21 } 22 cout << Quicksum << endl; 23 } 24 return 0; 25 }