学而思小猴编程C++题目,为父无法指导,请答疑!
图片被压缩了,请看链接
[](【腾讯文档】1
腾讯文档 腾讯文档-在线文档 https://docs.qq.com/doc/DY3lTSFl0V2dGdEFY )
```c++
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int q;
cin>>q;
bool flag[15]={true};
for(int i=1;i<=q;i++)
{
string s;
cin>>s;
int len=s.length();
for(int j=0;j<len;j++)
{
if(j%2==0)
{
if(s[j]=='L')
{
flag[i]=false;
}
}
else if(j%2==1)
{
if(s[j]=='R')
{
flag[i]=false;
}
}
}
}
for(int i=1;i<=q;i++)
{
if(flag[i])
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
return 0;
}
```
bool flag[15]={true};这种初始化方法并不能实现你想要的将所有数组成员初始化为true的目标,只有第一个是true,其它全是false
建议通过循环进行初始化为true
for(int i=0;i<15;i++)
flag[i] = true;
补充题干
贴图文字看不清楚,无法了解程序需求,是否可以发描述清楚大一点的图片。