Sort using vector in c++
The below program prints the input numbers in a sorted order.The program is implemented using c++.
Output :
Code :
#include<bits/stdc++.h> using namespace std; int main() { vector<int> s; int n; cout<<"Enter number of elements : "; cin>>n; for(int i=0;i<n;i++) { int t; cin>>t; s.push_back(t); } sort(s.begin(),s.end()); cout<<"Sorted Order :"<<endl; for(int i=0;i<n;i++) cout<<s[i]<<" "; return 0; }
Comments
Post a Comment