//就离谱,建议直接安照题目要求给定数组大小。 #include<stdio.h> //#include<stdbool.h> int main() { int T,j=0; int count=0; char jew[100000]; scanf("%d", &T); int first = 'A' - '0';//求出第一个字母的初始值,方便以此类推。 int a = first + 1; //printf("%d", 'B'-first-'0'); for (int i = 0; i < T; i++) { scanf("%s", &jew); while (jew[j]!='\0') { count += jew[j] - '0' - first + 1;// 很明显,在这里是直接减去了A,而我们默认为A=1;因此要把这个1加上去。 j++; }printf("%d\n",count); getchar();//字符串的输入存储中,不会自动跳过回车和空格,因此要注意清除缓冲区。 count = 0; j = 0; } return 0; }