vector_main.cpp 607 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "Vector.h"
  2. #include <time.h>
  3. using namespace std;
  4. void iosif(int count, int step)
  5. {
  6. clock_t start = clock();
  7. Vector v;
  8. for(int i = 0; i < count; i++) {
  9. v.add(i);
  10. }
  11. // cout << v;
  12. int i = 0;
  13. while(v.lenght > 1)
  14. {
  15. // cout << v;
  16. v.pop(i);
  17. i += step-1;
  18. i %= v.lenght;
  19. }
  20. // cout << v;
  21. clock_t end = clock();
  22. double sec = (double)(end - start) / CLOCKS_PER_SEC;
  23. cout << "time: " << sec << " answer: " << v[0];
  24. }
  25. int main() {
  26. iosif(1000, 3);
  27. iosif(5000, 3);
  28. iosif(10000, 3);
  29. iosif(50000, 3);
  30. }