Recent Post

Vector-Sort.cpp-HackerRank

Problem-You are given  integers.Sort the  integers and print the sorted order.

Store the  integers in a vector.Vectors are sequence containers representing arrays that can change in size.

Solution-

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() 
{
    int n,i;
    cin >> n;
    vector<int> num(n,0);
    for (i=0;i<n;i++)
    {
        cin >> num[i];
    }

    sort(num.begin(),num.end());
    for (int i = 0; i < n; i++)
    {
        cout<<num[i]<<" ";
    }
}

Link to the problem-

Result!

Comments

Popular posts from this blog

Caesar Cipher.c-HackerRank

Bon Appétit.c-HackerRank

Electronics Shop.c-HackerRank