以下為我的程式碼
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char in[300000];
char *p=in;
int state[7];
int nn,t;
int many_case;
scanf("%d\n",&many_case);
for(;many_case;--many_case){
//讀入x,y,z,w,n,m 數值
gets(in);
sscanf(in,"%d %d %d %d %d %d\n",&state[1],&state[2],&state[3],&state[4],&state[5],&state[6]);
//讀入每天的蘿蔔
gets(in);
p=strtok(in," ");
for(nn=0;;){
//沒有蘿蔔了
if(p==NULL){
printf("%dg\n",state[6]);
break;
}
t=atoi(p);
//早上先中毒
state[6]=state[6]-state[5]*nn;
if(state[6]<=0){
printf("bye~Rabbit\n");
break;
}
//吃蘿蔔
if(t==1 || t==2) state[6]+=state[t];
else if(t==3) state[6]-=state[t];
else{
state[6]-=state[t];
nn++;
}
p=strtok(NULL," ");
}
}
return 0;
}
還請高手為我解答,我哪裡出錯...
感激不盡