Horje
sort vector from smallest to largest Code Example
sort vector from smallest to largest
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	//sort vector from smallest to largest in cpp
	int n;
	cout << "Enter size of vector: ";
	cin >> n;

	vector<int> v(n);

	//fill vector
	for (int i = 0; i < n; i++)  cin >> v[i];
	
	//sort
	sort(v.begin(), v.end());

	//print vector
	for (int i = 0; i < n; i++)  cout << v[i] << " ";

	cout << "\n";

	return 0;
}




Cpp

Related
C if Code Example C if Code Example
warning: base will be initialized after Code Example warning: base will be initialized after Code Example
convert c   to C language Code Example convert c to C language Code Example
no argument but return value in c++ Code Example no argument but return value in c++ Code Example
c++ how to inherit from a template class Code Example c++ how to inherit from a template class Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8