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

int main()
{
	//sort vector from largest to smallest 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(),greater<int>());

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

	cout << "\n";

	return 0;
}




Cpp

Related
c++ starting syntaz Code Example c++ starting syntaz Code Example
reverse string upper to lower Code Example reverse string upper to lower Code Example
how to print items in c++ Code Example how to print items in c++ Code Example
arraylist equivalent cpp Code Example arraylist equivalent cpp Code Example
c++ enter name and surname one string Code Example c++ enter name and surname one string Code Example

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