首先,题主可能没有真正理解题意,因为在题意的叙述中,答案只可能是一个,当满足第一个答案时,其余的直接不执行了。其次while循环的大括号位置不对,他因该是在return 0之上结束,而且那个x和y颠倒了位置,标志位不需要使用 #include<bits/stdc++.h> using namespace std; int main(){     int n;     cin>>n;     while(n--){              string str;         cin>>str;         int n,x=0,y=0;         for(int i=0;i<str.length();i++)         {             if(str[i]=='N'||str[i]=='n')           x++;           if(str[i]=='Y'||str[i]=='y')           y++;         }     if(y>=(str.length()/2))     cout<<"pmznb"<<endl;         else     if(x>=(str.length()/2))     cout<<"lyrnb"<<endl;       else cout<<"wsdd"<<endl;     }     return 0; }

相关推荐

点赞 评论 收藏
转发
牛客网
牛客企业服务