Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:你代码太长In Reply To:你代码太长 Posted by:hustcswgy at 2011-08-03 19:41:52 #include <iostream> #include <string.h> #include <string> using namespace std; int i,n; long long ans; string str; int main(){ while (getline(cin,str)&&(str!="#")) { ans = 0; n = str.length(); for (i = 0; i < n; i++) { ans += (i + 1) * (str[i] == ' ' ? 0 : str[i] - 64); } cout<<ans<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator