该程序无法显示第二个迭代的输出
The program is not able to show the output from second iteration onwards
for(int i=0;i<T;i++) // t test cases
{
int flag=0; //flag variable to check the output
char A[3][3];
for(int j=0;j<3;j++) //Taking
for(int k=0;k<3;k++) //Input
cin>>A[j][k]; //in a character Array
//checking for letter 'l' in the character array and if other l's also exist or not
for(int j=0;j<2;j++)
for(int k=0;k<2;k++)
{
if(A[j][k]=='l')
{
if(A[j+1][k]=='l' && A[j+1][k+1]=='l')
flag++;
}
}
if(flag>0)
cout<<"yes"<<endl;
}
return 0;
}
这是我的代码,问题是在3*3个字符数组中检查是否存在类似
的模式l
ll
它适用于第一次迭代或第一个测试用例,但并未显示第二个迭代。
它可以正常工作,您可以在此处看到:在线gdb.com/r1vcs-fxn。
您没有看到结果,因为您没有"否" cout。
链接中的代码,以防万一停止工作:
#include <iostream>
using namespace std;
int main() {
const int T = 3;
cout << "T: " << T << endl;
for(int i=0;i<T;i++) // t test cases
{
int flag=0; //flag variable to check the output
char A[3][3];
for(int j=0;j<3;j++) //Taking
for(int k=0;k<3;k++) //Input
cin>>A[j][k]; //in a character Array
//checking for letter 'l' in the character array and if other l's also exist or not
for(int j=0;j<2;j++)
for(int k=0;k<2;k++) {
if(A[j][k]=='l') {
if(A[j+1][k]=='l' && A[j+1][k+1]=='l')
flag++;
}
}
cout << "Flags: " << flag << endl;
if(flag>0)
cout<<"yes"<<endl;
else
cout << "nope" << endl;
}
return 0;
}
相关文章:
- 集合上的输出迭代器:assign和increment迭代器
- 访问要输出的矢量迭代器元素
- 在静态库中使用输出迭代器时出现链接器错误
- 在插入容器之前转换输出迭代器
- 重复输出的类型是怎么回事,它如何区分迭代次数和 Ascii 代码?
- 根据 boost::iterator_facade 定义基于代理的输出迭代器
- 通过地图和打印内容迭代时,倒出输出
- 在循环输出中重用矢量 "Killed" 在几次迭代后
- 为什么每次“for”迭代都会输出 4 次
- 如何使用迭代器显示以下代码的输出
- C++:为什么输出迭代器不支持比较操作?
- 输入迭代器可以重复读取,而输出迭代器只能写入一次
- 该程序无法显示第二个迭代的输出
- 是C 正向/BIDI/随机迭代器总是输出迭代器
- Qt 使用迭代器重载了 qtextstream 输出运算符
- for 循环中的迭代次数错误.也得到意想不到的输出
- 在每次第 n 次迭代时将输出写入新文件
- 每n次迭代将输出写入一个文件
- stl风格的算法:如何管理输出迭代器
- 有趣的迭代输出