我有一个向量,用户输入一些字符串。我想保留用户输入的顺序,但删除任何重复的单词。我在网上找到的唯一方法是使用sort和unique,但由于我无法对向量进行排序,所以我陷入了困境。提前感谢您的帮助。
例如, 用户输入 -> hello there dog cat hello cat book
向量应该是 -> hello there dog cat book
目前我只有...
例如, 用户输入 -> hello there dog cat hello cat book
向量应该是 -> hello there dog cat book
目前我只有...
string s;
vector <string> myVec;
while (cin >> s){
myVec.push_back(s);
}
{code to sort vector}