c++字符串输入出现问题

问题遇到的现象和发生背景

字符串输入
为什么无法输入符号

img

问题相关代码,请勿粘贴截图

int a[maxline][maxline];
int b[maxline][maxline];
int column1,column2,row1,row2;
string the_chosen_symbol;
cout<<"请输入矩阵1的行数,和列数:"<<endl;
cin>>column1>>row1;
cout<<"请输入矩阵2的行数,和列数:"<<endl;
cin>>column2>>row2;
cout<<"请输入想要进行的运算“+”代表矩阵加法,”1-2“代表矩阵矩阵1减矩阵2,”2-1“代表矩阵2减矩阵1,”1*2“矩阵1乘矩阵2,“2*1”矩阵2乘矩阵1;"<<endl;
getline(cin,the_chosen_symbol);
cout<<"输入矩阵1"<<endl;
for(int i=0;i<row1;i++)
{for(int j=0;j<column1;j++)
cin>>a[i][j];
cout<<endl;}

运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

在getline前,清空一下输入缓冲区,否则前面输入时在缓冲区里还有换行符
https://blog.csdn.net/selina8921/article/details/79067941
cin.clear();
cin.sync(); //或者用cin.ignore();

https://en.cppreference.com/w/cpp/string/basic_string/getline

When consuming whitespace-delimited input (e.g. int n; std::cin >> n;) any whitespace that follows, including a newline character, will be left on the input stream. Then when switching to line-oriented input, the first line retrieved with getline will be just that whitespace. In the likely case that this is unwanted behaviour, possible solutions include:

  • An explicit extraneous initial call to getline
  • Removing consecutive whitespace with std::cin >> std::ws
  • Ignoring all leftover characters on the line of input with cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');