Print? Quicksum data consists of only 26 upper-case letters and spaces, and must start and end with an upper-case letter. In addition, Quicksum data can be any combination, including consecutive spaces.
Quicksum is the sum of the product of each letter location and letter value. The space value is 0, and the letter value is in alphabetical order, such as A = 1, B = 2, etc. The following is an example of "ACM" and "MID CENTRAL" computing Quicksum:
ACM: 1*1 + 2*3 + 3*13 = 46
Mid central: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650
Input
The test data contains multiple groups of data. The input is ended #.
Each group of data occupies one row, not ending with spaces. Each row contains a maximum of 255 characters and only letters or spaces.
Output
For each group of data, a separate row outputs its Quicksum.
Quicksum data consists of only 26 upper-case letters and spaces, and must start and end with an upper-case letter. In addition, Quicksum data can be any combination, including consecutive spaces.
Quicksum is the sum of the product of each letter location and letter value. The space value is 0, and the letter value is in alphabetical order, such as A = 1, B = 2, etc. The following is an example of "ACM" and "MID CENTRAL" computing Quicksum:
ACM: 1*1 + 2*3 + 3*13 = 46
Mid central: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650
Input
The test data contains multiple groups of data. The input is ended #.
Each group of data occupies one row, not ending with spaces. Each row contains a maximum of 255 characters and only letters or spaces.
Output
For each group of data, a separate row outputs its Quicksum.
[Plain]
# Include <stdio. h>
# Include <string. h>
Int main ()
{
Int I;
Int num;
Int sum;
Char str [255];
While (gets (str), str [0]! = '#')
{
Sum = 0;
Num = strlen (str );
For (I = 0; I <num; I ++)
{
If (str [I] = '')
{
Sum + = 0;
}
Else if (str [I]> = 'A' & str [I] <= 'Z ')
{
Sum + = (I + 1) * (str [I]-'A' + 1 );
}
}
Printf ("% d \ n", sum );
}
}
# Include <stdio. h>
# Include <string. h>
Int main ()
{
Int I;
Int num;
Int sum;
Char str [255];
While (gets (str), str [0]! = '#')
{
Sum = 0;
Num = strlen (str );
For (I = 0; I <num; I ++)
{
If (str [I] = '')
{
Sum + = 0;
}
Else if (str [I]> = 'A' & str [I] <= 'Z ')
{
Sum + = (I + 1) * (str [I]-'A' + 1 );
}
}
Printf ("% d \ n", sum );
}
}