fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. vector<int>v;
  8. int n;
  9. cin >> n;
  10. for(int i = 0; i < n; i++){
  11. int number;
  12. cin >> number;
  13. v.push_back(number);
  14. }
  15. for(int i = 0; i < n; i++){
  16. cout << v[i] << " " ;
  17. }
  18. cout << endl;
  19. for(size_t i = 0; i < v.size(); i++){
  20. cout << v[i] << " ";
  21. }
  22. cout << endl;
  23. v.pop_back();
  24. for(size_t i = 0; i < v.size(); i++){
  25. cout << v[i] << " ";
  26. }
  27. cout << endl;
  28. cout << v.front() << " " << v.back() << endl;
  29. sort(v.begin(), v.end());
  30. for(size_t i = 0; i < v.size(); i++){
  31. cout << v[i] << " ";
  32. }
  33. cout << endl;
  34. cout << v.size()<< endl;
  35. int m = 3;
  36. vector<int>::iterator it = find(v.begin(), v.end(), m);
  37. if (it != v.end()){
  38. cout << "true" << endl;
  39. }
  40. else{
  41. cout << "false" << endl;
  42. }
  43. v.clear();
  44. return 0;
  45. }
Success #stdin #stdout 0s 5292KB
stdin
5
9 7 6 1 2
stdout
9 7 6 1 2 
9 7 6 1 2 
9 7 6 1 
9 1
1 6 7 9 
4
false