Question
Two friends Niya and Druva visited a math’s magic zone. They had decided to play a puzzle game that asked them to alternate the order of Negative numbers and perfect square numbers. By using a quick sort algorithm and some rearranging logic to help them do the task. Identify the approach used by them to play the game and implement a C++ program with STL libraries. Don’t use arrays and sort algorithms for this program.
Sample Input
[-1, -3, 8, 12, -4, 4, 9, -7, 19, 25, 16]
Sample Output
[-3, 16, -7, 4, -1, 9, -4, 25]
#include #include #include using namespace std; void show(const vector &arr, const string &msg = "") { cout
Источник: https://stackoverflow.com/questions/780 ... -c-sorting