#include <iostream> #include <string.h> #include <stdio.h> using namespace std; int main() { int n,red,yellow; char data[50]; while(cin>>n) { if(n==0)break; cin>>data; red=0;yellow=0; for(int i=0;i<n;i++)//分别记录打进多少个球 { if(data[i]==‘R‘) red++; if(data[i]==‘Y‘) yellow++; } if(data[n-1]==‘B‘)//看是否进了7个球了 { if(red==7) cout<<"Red"<<endl; else cout<<"Yellow"<<endl; } else if(data[n-1]==‘L‘) { if(yellow==7) cout<<"Yellow"<<endl; else cout<<"Red"<<endl; } } return 0; }
原文:http://www.cnblogs.com/nefu929831238/p/5203444.html