#include<iostream>
#include<vector>
usingnamespace std;
template <typename T>
void printVector(vector<T> v1)
{
for (int i = 0; i<v1.size(); i++)
{
cout<<v1.at(i)<<endl;
}
}
int main(void)
{
int xxx;
double x;
vector<double> myVec;
cout<<"what is the size of array you want to input?";
cin>>xxx;
for(int i = 0; i <xxx; i++)
{
cout<<"enter your "<<i+1<<" value";
cin>>x;
myVec.push_back(x);
}
printVector(myVec);
cout<<endl;
cout<<"the size and capacity of the vecotr is "<<myVec.size()<<" and "<<myVec.capacity();
}
I have been studying vectors and it's awesome i just want to know is there a build in function/algorithm in vector that can display my values in the vector in descending/ascending order?
I don't really understand the whole concept about sorting, i am trying to code for descending order. Normally for an array you change the for loop but in this case i need to do something about the sort, what are the things i need to do?