杭电ACM 2021题,不知为什么不能AC?

2024-12-03 02:24:41
推荐回答(1个)
回答1:

//以下代码已AC
#include
int main()
{
int n, m;
int sum, i;
while(scanf("%d", &n) != EOF)
{
if(n == 0)break;
sum = 0;
for(i = 1; i <= n; i++)
{
scanf("%d", &m);
switch(m % 10)
{
case 1:
case 2:
case 5:
sum += 1;
break;
case 3:
case 4:
case 6:
case 7:
sum += 2;
break;
case 8:
case 9:
sum += 3;
break;
}
switch((m / 10) % 10)
{
case 1:
case 5:
sum += 1;
break;
case 2:
case 6:
sum += 2;
break;
case 3:
case 7:
sum += 3;
break;
case 4:
case 8:
sum += 4;
break;
case 9:
sum += 5;
break;
}
sum += (m / 100);
}
printf("%d\n", sum);
}
return 0;
}