Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #include <iostream>
  2. #include "BST.h"
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. srand(time(NULL));
  10. int N = rand() % 100;
  11. int A[100];
  12. int min = INT_MAX;
  13. int max = 0;
  14. int k = (rand() % 100) + 100;
  15. int p = (rand() % 100) + 100;
  16. int numk = 0;
  17. int lessp = 0;
  18. for (int i = 0; i < N; i++) {
  19. A[i] = (rand()%100)+100;
  20. if (A[i] > max)
  21. max = A[i];
  22. if (A[i] < min)
  23. min = A[i];
  24. if (A[i] == k)
  25. numk++;
  26. if (A[i] < p)
  27. lessp++;
  28. }
  29. if (numk == 0) numk = -1;
  30. if (lessp == 0) lessp = -1;
  31. BST t;
  32. for (int i = 0; i < N; i++) {
  33. t.Insert(A[i]);
  34. }
  35. cout << "ILOSC AUKCJI: " << N + 1 << endl;
  36. cout << "----------------------------------------------" << endl;
  37. cout << "WYGENEROWANA TABLICA A: " << endl;
  38. for (int i = 0; i < N; i++) {
  39. cout << A[i] << " ";
  40. }
  41. cout << endl << "----------------------------------------------" << endl;
  42. cout << "ROZNICA: " << t.AuctionDiff() << endl;
  43. cout << "OOCZEKIWANO: " << max - min;
  44. cout << endl << "----------------------------------------------" << endl;
  45. cout << "WYLOSOWANA LICZBA k: " << k ;
  46. cout << endl << "----------------------------------------------" << endl;
  47. cout << "LICZBA AUKCJI Z CENA k: " << t.HowManyAuctions(k) << endl;
  48. cout << "OOCZEKIWANO: " << numk ;
  49. cout << endl << "----------------------------------------------" << endl;
  50. cout << "WYLOSOWANA LICZBA p: " << p;
  51. cout << endl << "----------------------------------------------" << endl;
  52. cout << "LICZBA AUKCJI Z CENA MNIEJSZA NIZ p: " << t.LowerThan(p) << endl;
  53. cout << "OOCZEKIWANO: " << lessp;
  54. cout << endl << "----------------------------------------------" << endl;
  55. system("pause");
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement