We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
题目要求:
修改前一题的程序,使其只打印不重复的元素。你的程序应该使用 unique_copy。
给出的答案:
int main() { vector<int> v; istream_iterator<int> int_it(cin), int_eof; unique_copy(int_it, int_eof, back_inserter(v)); sort(v.begin(), v.end()); copy(v.begin(), v.end(), ostream_iterator<int>(cout, " ")); cout << endl; return 0; }``` 由于输入的整数并不一定是有序的,所以这里采用unique_copy对vector进行插入不能达到去重效果,而应该在vector排完序后再用unique_copy进行输出,就能达到题目要求。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目要求:
给出的答案:
The text was updated successfully, but these errors were encountered: