#include<stdio.h> int main() { int i ,na,nb,n,ahan[100] ,ahua[100] ,bhan[101] ,bhua[100] , counta= 0 , countb = 0; scanf("%d%d",&na,&nb); scanf("%d",&n) ; for( i = 0 ; i < n ; i ++ ) scanf("%d%d%d%d",&ahan[i],&ahua[i],&bhan[i],&bhua[i]); for(i=0;i<n;i++) { if((ahua[i] == (ahan[i] + bhan[i]) )&& (bhua[i] == (bhan[i] + bhan[i]))) continue ; if( ahua[i] == (ahan[i] + bhan[i]) ) { counta ++ ; na -- ; if(na < 0 ) {printf("A\n%d\n",countb); break ;} } else if (bhua[i] == (ahan[i] + bhan[i])) { countb ++ ; nb -- ; if(nb < 0 ) {printf("B\n%d\n",counta); break ;} } } return 0; }
本题目重点在于continue的使用,通过continue实现同赢或同输继续比赛;
第二个关键点在于甲乙的极限杯数,并不是达到这个极限杯数后就会醉倒而是超过极限杯数才会醉倒所以,counta==na作为最后的if判断条件得出的结果是不对的
标签:7.17,na,scanf,d%,100,杯数 From: https://www.cnblogs.com/xuxingkai/p/17561604.html