Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. int main() {
  2. int zabawa[65536];
  3. HeapByBlaze xD;
  4. char input = '*';
  5. int *arra = nullptr;
  6. int insert;
  7. int maxCzyMin = 1;
  8. int tempRozm;
  9. vector<int> xddd;
  10. while (input != 'q') {
  11. cin >> input;
  12. switch (input) {
  13. case '+':
  14. cin >> insert;
  15. xddd.push_back(insert);
  16. break;
  17. case '-':
  18. cout << xddd.back() << '\n';
  19. xddd.pop_back();
  20. break;
  21. case 'p':
  22. tempRozm = xddd.size();
  23. arra = new int[tempRozm];
  24. for (int i = 0; i < tempRozm; i++) {
  25. arra[i] = xddd[i];
  26. }
  27. if (maxCzyMin % 2 == 1)
  28. buildMaxHeap(arra, tempRozm);
  29. else
  30. buildMinHeap(arra, tempRozm);
  31. for (int i = 0; i < tempRozm; i++) {
  32. cout << arra[i] << ' ';
  33. } cout << '\n';
  34. break;
  35. case 'r':
  36. int rozmiar, podawana;
  37. xddd.clear();
  38. cin >> rozmiar;
  39. for (int i = 0; i < rozmiar; i++) {
  40. cin >> podawana;
  41. xddd.push_back(podawana);
  42. }
  43. break;
  44. case 's':
  45. maxCzyMin++;
  46. default:
  47. break;
  48. }
  49. }
  50.  
  51. delete[] arra;
  52. return 13 / 56;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement