谢谢分享! 第19行,上一轮i++后可能越界,应该增加一句判断:while ((i < n) && (data[i] <= -1)) 然后,main()开头输入写一下cin >> string再转vector<int>就完美了