HackerRank C++ Vector-Sort




You are given N integers.Sort the N integers and print the sorted order.



  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7. int main()
  8. {
  9. int n,i;
  10. cin>>n;
  11. vector<int> arr(n);
  12. for(i=0;i<n;i++)
  13. cin>>arr[i];
  14. {
  15. sort(arr.begin(),arr.end());
  16. }
  17. for(i=0;i<n;i++)
  18. {
  19. cout<<arr[i]<<" ";
  20. }
  21. return 0;
  22. }




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube