真的找不出錯啊...
自己帶測資進去顯示的m是對的,但如果m>0(兔子 still alive)就無法正確輸出
求解 感謝
#include <stdio.h>
int main() {
int N;
scanf("%d", &N);
for(int i=0;i<N;i++) {
int x, y, z, w, n, m, carrot, poison_state=0, test=0;
scanf("%d%d%d%d%d%d", &x, &y, &z, &w, &n, &m);
while(scanf("%d", &carrot)!=EOF) {
m-=poison_state*n;
switch(carrot) {
case 0:
break;
case 1:
m+=x;
break;
case 2:
m+=y;
break;
case 3:
m-=z;
break;
case 4:
m-=w;
poison_state++;
break;
}
if(m<=0) {
printf("bye~Rabbit\n");
test=1;
break;
}
}
if(test==0)
printf("%dg\n", m);
}
return 0;
}