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

Re:你代码太长

Posted by cz_insane at 2013-02-15 17:26:33 on Problem 3094
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:
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