1 #include <iostream>
2 #include <vector>
3 #include <algorithm>
4
5 using std::string;
6 using std::cin;
7 using std::cout;
8 using std::endl;
9
10 int main(){
11
12 std::vector< int > v;
13 int s;
14 std::vector<int>::iterator it;
15
16 while(cin>>s)
17 v.push_back(s);
18
19 //使用排序算法
20 sort(v.begin(),v.end());
21
22 //使用迭代器
23 for(it=v.begin();it!=v.end();it++){
24 cout<<*it<<endl;
25 }
26
27 return 0;
28 }
容器,迭代器,算法使用小例
最新推荐文章于 2023-01-17 13:45:03 发布