
#include <stdio.h>#include <string.h>int main(){int fishs, time, bait, t, b;char command[10];fishs = 0;time = 0;bait = 0;t = 0;b = 0;while(gets(command) != NULL) {if(strcmp(command, "") == 0) {printf("%dn", fishs);time = 0;fishs = 0;bait = 0;t = 0;b = 0;continue;}if(strcmp(command, "fish") == 0) {if(fishs) {time++;}if(bait) {if(fishs) {t++;}}if(!fishs) {if(bait) {bait--;fishs++;time = 0;t = 0;}} else {if(time >= 7 || t >= 3) {if(bait) {bait--;fishs++;time = 0;t = 0;}}}}else if(strcmp(command, "bait") == 0) {if(fishs) {time++;}if(bait < 3) {b++;}if(b == 2) {b = 0;if(bait < 3) {bait++;}}}else if(strcmp(command, "lunch") == 0) {if(fishs) {time++;}}}printf("%dn", fishs);return 0;}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)