Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication65.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stack>
- #include <iostream>
- using namespace std;
- void main()
- {
- int number;
- stack <int> S;
- stack <int> P;
- stack <int> Q;
- int count;
- cout << "Broj na chislata za vavezdane: ";
- cin >> count;
- for (int i = 0; i < count; i++)
- {
- cin >> number;
- S.push(number);
- }
- while (!S.empty())
- {
- int element = S.top();
- if (element >= 0)
- {
- P.push(element);
- }
- else
- {
- Q.push(element);
- }
- S.pop();
- }
- //Извеждане на съдържанието
- cout << "Polozitelni: " << endl;
- while (!P.empty())
- {
- cout << P.top() << " ";
- P.pop();
- }
- cout << endl << "Otricatelni: " << endl;
- while (!Q.empty())
- {
- cout << Q.top() << " ";
- Q.pop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment