POJ3094Quicksum

转载请注明出处:優YoU   http://user.qzone.qq.com/289065406/blog/1299074589 

 提示:不用提示了= = 超级水。。。。别弄错权值就是了。。

 1 //Memory Time 
2 //224K 16MS
3
4 #include<iostream>
5 #include<cstring>
6 using namespace std;
7
8 int value[91];
9
10 void value_alphabet(void)
11 {
12 int i,j;
13 for(i='A',j=1;i<='Z';i++,j++)
14 value[i]=j;
15 value[' ']=0;
16 return;
17 }
18
19
20 int main(void)
21 {
22 char input[10000];
23 for(;;)
24 {
25 value_alphabet();
26
27 gets(input);
28 if(!strcmp(input,"#"))
29 return 0;
30
31 const int length=strlen(input);
32 int i,quicksum;
33 for(i=0,quicksum=0;i<length;i++)
34 quicksum+=(i+1)*value[input[i]];
35 cout<<quicksum<<endl;
36 }
37 return 0;
38 }
原文地址:https://www.cnblogs.com/lyy289065406/p/2120494.html