Advertisement
Guest User

zyc mi sie juz nie chce2

a guest
Oct 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10. priority_queue < int > kolejka;
  11. int liczba = 0;
  12.  
  13. while(cin >> liczba != 0);
  14. {
  15. if(liczba == 0)
  16. {
  17. return 0;
  18. }
  19.  
  20. if(liczba > 0)
  21. {
  22. kolejka.push(liczba);
  23. }
  24.  
  25. if(liczba < 0 && !kolejka.empty())
  26. {
  27.  
  28. for(int i = 0; i < -liczba ; i++)
  29. {
  30.  
  31. if(kolejka.empty())
  32. {
  33. return 0;
  34. }
  35.  
  36. if(i = 0)
  37. {
  38. cout<<kolejka.top();
  39. }
  40.  
  41. else{
  42. cout <<" "<<kolejka.top();
  43. kolejka.pop();
  44.  
  45. }
  46. }
  47. cout<<endl;
  48. }
  49.  
  50. }
  51.  
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement