There is a string ss of length 33, consisting of uppercase and lowercase English letters. Check if it is equal to "YES" (without quotes), where each letter can be in any case. For example, "yES", "Yes", "yes" are all allowable.
Input
The first line of the input contains an integer tt (1≤t≤1031≤t≤103) — the number of testcases.
The description of each test consists of one line containing one string ss consisting of three characters. Each character of ss is either an uppercase or lowercase English letter.
Output
For each test case, output "YES" (without quotes) if ss satisfies the condition, and "NO" (without quotes) otherwise.
You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).
Examples
| Inputcopy | Outputcopy |
|---|---|
10 YES yES yes Yes YeS Noo orZ yEz Yas XES |
YES YES YES YES YES NO NO NO NO NO |
Note
The first five test cases contain the strings "YES", "yES", "yes", "Yes", "YeS". All of these are equal to "YES", where each character is either uppercase or lowercase.
思路:
将输入的字符串中的字符全部转为小写,判断条件两个:
(1)是否为三个字符,不是直接输出NO
(2)判断是否为yes,是则输出YES,否则输出NO
代码:
#include <iostream>
using namespace std;
int main()
{
int n;
cin >>n;
while(n--)
{
string s;
cin >>s;
if(s.size() != 3)
{
cout <<"NO"<<endl;
continue;
}
for(int i=0;i<s.size();i++)
if(s[i] >= 'A' && s[i] <= 'Z')
s[i] += 32;
int flag = 0;
if(s[0] == 'y' && s[1] == 'e' && s[2] == 's') cout <<"YES"<<endl;
else cout <<"NO"<<endl;
}
return 0;
}
本题是水体很简单,知道判断条件就可以做出来
3384

被折叠的 条评论
为什么被折叠?



