-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVector-Sort.cpp
More file actions
42 lines (35 loc) · 737 Bytes
/
Copy pathVector-Sort.cpp
File metadata and controls
42 lines (35 loc) · 737 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
38
39
40
41
42
/*
Input Format
The first line of the input contains N where N is the number of integers.
The next line contains N integers.
Output Format
Print the integers in the sorted order one by one in a single line followed by a space.
Sample Input
5
1 6 10 8 4
Sample Output
1 4 6 8 10
*/
#include<iostream>
#include <bits/stdc++.h>
#include<vector>
#include<algorithm>
// # define
using namespace std;
int main(){
vector<int> vi; //creates an empty vector of integers
int t;
cin >> t;
while (t>0)
{
int input;
cin >> input;
vi.push_back(input);
t--;
}
sort(vi.begin(), vi.end());
for(auto i = vi.begin(); i != vi.end(); i++){
cout << *i << " ";
}
return 0;
}