Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Cu H2O

Posted by KatrineYang at 2016-09-28 12:58:08 on Problem 3094 and last updated at 2016-09-28 12:58:31
In Reply To:水题,没有开数组,0MS,贴代码,供参考 Posted by:denganliang at 2011-03-23 14:41:53
#include <iostream>
#include <string>
using namespace std;

int toInt(char c){
	if(c != 32) return c-'A'+1;
	return 0;
}
string s;
int main() {
	while(getline(cin,s)){
		if(!(s[0]-'#')) break;
		int sum = 0, len = s.length();
		for(int i = 0; i < len; i++) sum += (i+1)*toInt(s[i]);
		cout << sum << endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator