Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- queue<int> initial;
- queue<int> add;
- initial.push(-1);
- initial.push(2);
- initial.push(0);
- initial.push(4);
- initial.push(-5);
- initial.push(-6);
- bool isNegativeFound = true;
- while (isNegativeFound)
- {
- isNegativeFound = false;
- for (size_t i = 0; i < initial.size(); i++)
- {
- int element = initial.front();
- initial.pop();
- if (element < 0)
- {
- add.push(element);
- isNegativeFound = true;
- }
- else
- {
- initial.push(element);
- }
- }
- }
- while (!add.empty())
- {
- initial.push(add.front());
- add.pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement