Hackerrank- Vector Sort problem(solved)

#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> vec;
    int size;
    cin>>size;
    for(int i=0;i<size;i++)
    {
        int a;
        cin>>a;
        vec.push_back(a);
    }
     sort(vec.begin(),vec.end());
     for(int i=0;i<size;i++)
     cout<<vec[i]<<" ";
    return 0;
}
Hac

Comments

Popular posts from this blog

Hackerrank-Accessing Inherited Functions problem-Inheritance

Inheritance- Code with Harry-Lecture 41 solution (Multiple inheritance)