vector<int> a = {1, 5, -2, 14, -9, 0, -1, 5, -25}; // given array
vector<int> q; // array after choosing negative values from a
for(auto &i : a)
if(i < 0)
q.push_back(i);
sort(q.begin(), q.end()); // sort in ascneding oerder
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
vector<int> a = {1, 5, -2, 14, -9, 0, -1, 5, -25}; // given array
vector<int> q; // array after choosing negative values from a
for(auto &i : a)
if(i < 0)
q.push_back(i);
sort(q.begin(), q.end()); // sort in ascneding oerder