输入这个二维数组的板块写不好,就是二行注释之间的那一块,求正确的代码
试题是检验每个字符串里面有没有PA~T子串。
#include<iostream>
int main()
{
int i = 0, j = 0, n;
char str[10][100]={"PAT","PATTT","PART"};
//分割线1
std::cin >> n;
while (i < n)
{
while (std::cin >> str[i][j])
{
++j;
}
char a = getchar();
++i;
}
//分割线2
//下面的处理过程经过调试正确
for (i = 0; i < n; ++i)
{
for (j = 0; str[i][j] != '\0'; ++j)
if (str[i][j] == 'P' && str[i][j + 1] == 'A')
{
j += 1;
for (j; str[i][j] != '\0'; ++j)
{
if (str[i][j]== 'A')
continue;
else if(str[i][j]=='T')
{
std::cout << "YES" << '\n';
break;
}
else
{
std::cout << "NO" << '\n';
break;
}
}
}
}
return 0;
}