练习 Vector 的使用
读入若干个数字,然后对其进行从大到小排序,依次输出这些数字,并且输出它们的个数
#include <iostream>
#include <algorithm>
using std::vector;
using std::cin;
using std::cout;
using std::greater;
using std::endl;
int main(){
vector<int> v;
int input;
while(cin >> input){
auto iter = find(v.begin(), v.end(), input);
if(iter == v.end()){
v.push_back(input);
}
}
sort(v.begin(), v.end(), greater<int>());
for (int i = 0; i < v.size(); i++){
cout << v[i] << endl;
}
cout << v.size() << endl;
return 0;
}