#include <stdio.h>
// Fnlock
// 这题就是字符串问题
int main(int argc,const char *argv[])
{
int n;
int i;
scanf("%d",&n);
getchar();
char arr[110];
int t=0;
while(n--)
{
t=0;
gets(arr);
for(i=0; arr[i]!='\0';i++)
{
if(arr[i]=='C') t+=12;
else if(arr[i]=='H') t+=1;
else t+=16;
}
printf("%d\n",t);
}
return 0;
}
1371Problem A:化学题
本文介绍了一个简单的C语言程序,该程序读取一系列字符并根据特定规则为每个字符分配分数。字符'C'得12分,'H'得1分,其他字符得16分。程序通过循环遍历字符串中的每个字符并累计得分。

被折叠的 条评论
为什么被折叠?



