본문 바로가기
C++

[HackerRank]Vector-Sort - Easy

by 호아나트 2019. 10. 29.
반응형

https://www.hackerrank.com/challenges/vector-sort/problem

 

Vector-Sort | HackerRank

Learn about the container vector. Sort a vector and print the sorted vector.

www.hackerrank.com

#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 */   
    int n;
    int res;
    vector<int>v;
    cin>>n;
for(int i =0;i<n;i++)
{
    cin>>res;
    v.push_back(res);
}
sort(v.begin(),v.end());

for(vector<int>::iterator it=v.begin();it!=v.end();it++)
{
    cout<<*it<<' ';
}
    return 0;
}
반응형

'C++' 카테고리의 다른 글

[HackerRank]Vector-Erase-Easy  (0) 2019.10.29
[HackerRank] Virtual Functions -Medium  (0) 2019.10.28
[HackerRank] Exceptional Server - Easy  (0) 2019.10.25
[HackerRank] Inherited Code - Easy  (0) 2019.10.25
[HackerRank] Box it! - easy  (0) 2019.10.23

댓글