Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "BST.h"
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int N = rand() % 100;
- int A[100];
- int min = INT_MAX;
- int max = 0;
- int k = (rand() % 100) + 100;
- int p = (rand() % 100) + 100;
- int numk = 0;
- int lessp = 0;
- for (int i = 0; i < N; i++) {
- A[i] = (rand()%100)+100;
- if (A[i] > max)
- max = A[i];
- if (A[i] < min)
- min = A[i];
- if (A[i] == k)
- numk++;
- if (A[i] < p)
- lessp++;
- }
- if (numk == 0) numk = -1;
- if (lessp == 0) lessp = -1;
- BST t;
- for (int i = 0; i < N; i++) {
- t.Insert(A[i]);
- }
- cout << "ILOSC AUKCJI: " << N + 1 << endl;
- cout << "----------------------------------------------" << endl;
- cout << "WYGENEROWANA TABLICA A: " << endl;
- for (int i = 0; i < N; i++) {
- cout << A[i] << " ";
- }
- cout << endl << "----------------------------------------------" << endl;
- cout << "ROZNICA: " << t.AuctionDiff() << endl;
- cout << "OOCZEKIWANO: " << max - min;
- cout << endl << "----------------------------------------------" << endl;
- cout << "WYLOSOWANA LICZBA k: " << k ;
- cout << endl << "----------------------------------------------" << endl;
- cout << "LICZBA AUKCJI Z CENA k: " << t.HowManyAuctions(k) << endl;
- cout << "OOCZEKIWANO: " << numk ;
- cout << endl << "----------------------------------------------" << endl;
- cout << "WYLOSOWANA LICZBA p: " << p;
- cout << endl << "----------------------------------------------" << endl;
- cout << "LICZBA AUKCJI Z CENA MNIEJSZA NIZ p: " << t.LowerThan(p) << endl;
- cout << "OOCZEKIWANO: " << lessp;
- cout << endl << "----------------------------------------------" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement