Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- int main(){
- int liczba,zakres,temp;
- priority_queue < int > kolejka;
- do{
- cin >> liczba;
- if(liczba > 0){
- kolejka.push(liczba);
- }
- else if(liczba < 0 && !kolejka.empty()){
- zakres = -liczba;
- for(int i=0; i < zakres; i++){
- if(kolejka.empty())break;
- temp = kolejka.top();
- cout << temp;
- kolejka.pop();
- if (i!=(zakres-1) && !kolejka.empty()) cout << " ";
- }
- cout << endl;
- }
- else if (liczba == 0) break;
- }while(liczba != 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement