12345678910111213141516171819202122232425262728293031323334353637 |
- #include "List.h"
- #include <iostream>
- #include <time.h>
- using namespace std;
- void iosif(int count, int step)
- {
- clock_t start = clock();
- List<int> l;
- for(int i = 0; i < count; i++) {
- l.add(i);
- }
- int i = 0;
- while(l.lenght > 1) {
- l.pop(i);
- i += step - 1;
- i %= l.lenght;
- }
- clock_t end = clock();
- double sec = (double)(end - start) / CLOCKS_PER_SEC;
- cout << "time: " << sec << " answer: " << l[0] << endl;
- }
- int main() {
- iosif(1000, 3);
- iosif(5000, 3);
- iosif(10000, 3);
- iosif(50000, 3);
- iosif(100000, 3);
- iosif(500000, 3);
- iosif(1000000, 3);
- }
|