TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday, 24 August 2020

Sorting Vector In C++|Sorting Vector In C++ Program| Sorting Vector In C++ Example| Sorting Vector In C++ Syntax| Sorting Vector In C++ In Hindi

 

Sorting Vector In C++

Sorting a vector in C++ can be done by using std::sort(). It is defined in<algorithm> header. To get a stable sort std::stable_sort is used. It is exactly like sort() but maintains the relative order of equal elements.


image of Sorting Vector In C++

Fig:Sorting Vector In C++


Program:

#include<iostream.h>

#include<vector.h>

#include<algorithm.h>

#include<conio.h>

void main()

{

vector<int> v={10,9,8,6,7,2,5,1};

cout<<”elements before sorting”<<endl;

for(const auto &i:v)

cout<<i <<endl;

cout<<”elements after sorting”<<endl;

sort(v.begin(),v.end());

for(const auto &i:v)

cout<<i <<endl;

getch();

}


Output:

Elements before sorting:

10

No comments:

Post a Comment