网易编程题涂棋盘那道题有点疑惑

我若是使用string s[50],通不过,提示段错误,但是使用二维数组就能正确通过,为什么呢?
又测试了,定义string s[51]可以正常通过
#include <iostream>
#include <cstring>
using namespace std;

int main() {
int n;
//char s[50][50];
string s[50];
int max=0;
cin >> n;
for(int i=0;i<n;i++)
{
//for(int j=0;j<n;j++)
//{
//    cin >> s[i][j];
//}
cin >> s[i];
}

for(int i=0;i<n;i++)
{
int c = 0;
int j=0;
while(j<(n-1))
{
c=1;
while(s[j][i]==s[j+1][i])
{
c++;
j++;
}
if(max < c)
{
max = c;
}
j++;
}
}

cout << max;
return 0;
}#网易#
全部评论

相关推荐

哈哈哈哈哈哈哈哈哈哈这个世界太美好了
凉风落木楚山秋:毕业出路老师不管,你盖个章他好交差就完事了,等你盖完毕业了就不关他事情了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务