Description
If we define each of the upper case letters a number, that is, 1 for A, 2 for B, 3 for C, ... 25 for Y, 26 for Z, we can calculate a mark for any word or sentence.
We believe that 100 points is the full mark, so for those word with a mark larger than 100, we should just ignore that, with a label ``INVALID". Then let's see interesting results:
What is the most important for your success?
- HARD WORK? H+A+R+D+W+O+R+K=8+1+18+4+23+15+18+11=98
- KNOWLEDGE? K+N+O+W+L+E+D+G+E=11+14+15+23+12+5+4+7+5=96
- MONEY?(72)
- LUCK?(47)
- ATTITUDE! A+T+T+I+T+U+D+E=1+20+20+9+20+21+4+5=100
So just be with good attitude and you will be on your way to success.
Input
For each case of the input, it contains a single line. For each line, some characters will appear with maybe some of them being upper case letters. All characters are printable. Each line will have at most 127 characters.
Output
For each case, you should only pay attention to upper case letters and calculate the total points. If it is over 100, ``INVALID" should be returned. Or you should print the exact point of that.
Sample Input
DELICIOUS FOOD YY, and YY again! did i lose anything?
Sample Output
INVALID 100 0
#include <stdio.h> #include <string.h> char str1[200], str2[200]; int main() { int ans; while(scanf("%s", str1) != EOF) { gets(str2); int len1 = strlen(str1), len2 = strlen(str2); ans = 0; for(int i = 0; i < len1; i++) { if(str1[i] >= 'A' && str1[i] <= 'Z') { ans += str1[i] - 'A' + 1; } } for(int i = 0; i < len2; i++) { if(str2[i] >= 'A' && str2[i] <= 'Z') { ans += str2[i] - 'A' + 1; } } if(ans > 100) { printf("INVALID\n"); } else { printf("%d\n", ans); } } return 0; }