0
Vector, sort() error!!
Initially a vector named number is empty. This program is supposed to take input(numbers of type double) from the user to store in the vector (named numbers). The problem here is the statement sort(numbers)[line no.60 in my code]. As there are no values initially in the vector, the statement sort(numbers) create a build error! Please help me get out of this situation. https://code.sololearn.com/cR5U4LawMhSe/?ref=app //It might be problematic to run this code on mobile
4 odpowiedzi
0
Chetan Satpute sorry, my mistake.
Just add sort(number.begin(), number.end());
https://code.sololearn.com/cz3SPqqIGq1n/?ref=app
I did one example of vector sorting
+ 1
Unfortunately, here, you can't do the thing you wanted, but you can sort the vector like this
for(auto x:number){
cout<<x<<endl;
}
+ 1
Dejan Francuz thank you, it worked.
0
#Dejan Francuz
for (auto x : number ) {
cout <<x<<endl;
}
Just prints the value in vector it does not sort them
Please help