|
@@ -1,7 +1,34 @@
|
|
|
#include "CircleList.h"
|
|
|
+#include <time.h>
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
+
|
|
|
+void iosif(int count, int step)
|
|
|
+{
|
|
|
+ clock_t start = clock();
|
|
|
+ CircleList<int> l;
|
|
|
+ for(int i = 0; i < count; i++) {
|
|
|
+ l.add(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ int i = 0;
|
|
|
+ Node<int>* currentNode = l.get_start();
|
|
|
+ while(l.lenght > 1)
|
|
|
+ {
|
|
|
+ if(i % step == 0) {
|
|
|
+ l.pop(currentNode);
|
|
|
+ }
|
|
|
+ currentNode = currentNode->next;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ clock_t end = clock();
|
|
|
+ double sec = (double)(end - start) / CLOCKS_PER_SEC;
|
|
|
+ cout << "time: " << sec << " answer: " << l[0] << endl;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
int main() {
|
|
|
CircleList<int> l;
|
|
|
for(int i = 0; i < 10; i++) {
|
|
@@ -16,4 +43,12 @@ int main() {
|
|
|
cout << l << endl;
|
|
|
l.pop(2);
|
|
|
cout << l << endl;
|
|
|
+
|
|
|
+ iosif(1000, 3);
|
|
|
+ iosif(5000, 3);
|
|
|
+ iosif(10000, 3);
|
|
|
+ iosif(50000, 3);
|
|
|
+ iosif(100000, 3);
|
|
|
+ iosif(500000, 3);
|
|
|
+ iosif(1000000, 3);
|
|
|
}
|