-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector-Sort
More file actions
37 lines (31 loc) · 760 Bytes
/
Copy pathVector-Sort
File metadata and controls
37 lines (31 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// declare a vector
// establish N size array
// input each value of array
// use v.push_back(x); to append the array
// use sort(v.begin(), v.end()); to sort the array from beg to end
// update size variable to size of array using v.size();
// print out array of v
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
vector<int> v;
int x;
int n;
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
for(int i = 0; i < v.size(); i++)
{
cout << v[i] << " ";
}
return 0;
}