gpt4 book ai didi

C++:,当我使用字符串数组时,出现字符串下标超出范围

转载 作者:行者123 更新时间:2023-11-28 01:38:03 25 4
gpt4 key购买 nike

<分区>

我只是想知道为什么会出现字符串下标超出范围的问题,我已经初始化了字符串数组。谢谢。

#include<bits/stdc++.h>
#define N 100000
using namespace std;
string s[N + 5] = {}, ss[N + 5] = { " " }, fs[N + 5] = { " " };
int main()
{
int n, x; char c;
cin >> n;
for (int i = 0; i<n; ++i)
{
for (int j = 0; j<6; ++j)
{
scanf("%c", &c);//the error comes here.
if (c == ' ') continue;
s[i] += c;
}
ss[i] = s[i] + s[i];
for (int j = 5; j >= 0; --j) fs[i][j] = s[i][5 - j];
}
int flag = 0;
for (int i = 0; i<n; ++i)
{
for (int j = 0; j<n; ++j)
{
if (i == j) continue;
if (find(s[i], fs[j]) || find(s[i], ss[j]))
{
flag = 1; break;
}
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com