我的思路是用vector申请N行,每一行是一个字符串,结构编译器报错了,求改正后的代码,谢谢。
```c++
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
int N;
cin >> N;
vector<string>e(N);
for (int i = 0; i < N; ++i)
{
cin >> e[i];
for (int j = 0; j < e[i].length(); ++j)
{
if (e[i][j] == e[i][j + 1] ==e[i][j + 2])
{
for (int k = j + 2; k < e[i].length() - (j + 2); ++k)
e[k] = e[k + 1];
e[i][e[i].length() - (j + 2)-1]='\0';
}
else if (e[i][j] == e[i][j + 1] && e[i][j + 2] == e[i][j + 3]&& e[i][j + 4] != e[i][j + 5])
{
for (int k = j + 2; k < e[i].length() - (j + 2); ++k)
e[k] = e[k + 1];
e[i][e[i].length() - (j + 2) - 1] = '\0';
}
else if(e[i][j] == e[i][j + 1] && e[i][j + 2] == e[i][j + 3] && e[i][j + 4] == e[i][j + 5])
{
for (int k = j + 2; k < e[i].length() - (j + 2); ++k)
e[k] = e[k + 1];
e[i][e[i].length() - (j + 2) - 1] = '\0';
}
}
}
for (int i = 0; i < N; ++i)
cout<<e[i]<<endl;
return 0;
}
![2AE7E16D6F1F258B659C04A814E19BA8.png img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/519376342036177.png?x-oss-process=image/auto-orient,1/resize,w_320,m_lfit)
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/220386342036169.png '38092E3420D4223C85D172348B6A1C31.png')
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/964296342036133.png 'B9D44B8AE80AA903A80C5F0247EB63E1.png')