//用STL的sort()排序,unique()去重即可 #include <iostream> #include <cstdlib> #include <cmath> #include <deque> #include <algorithm> #include <numeric> #include <iterator> #include <sstream> #include <iomanip> #include <vector> #include <string> using namespace std; int main() { int n; int num; deque<int> q; cin>>n; for(int i=0;i<n;i++) { cin>>num; q.push_back(num); } sort(q.begin(),q.end()); deque<int>::iterator lt; lt=unique(q.begin(),q.end()); q.erase(lt,q.end()); cout<<q.size()<<endl; copy(q.begin(),q.end(),ostream_iterator<int>(cout," ")); return 0; }
解题思路:
注意事项:
参考代码:
0.0分
0 人评分
IP判断 (C语言代码)浏览:1415 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:694 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:458 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:451 |
【出圈】 (C语言代码)浏览:554 |
【密码】 (C语言代码)浏览:333 |
【数组的距离】 (C语言代码)浏览:728 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:522 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:535 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:620 |