jezv 1 년 전
부모
커밋
a7dbd8e4cb
5개의 변경된 파일46개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      CircleList.h
  2. 1 1
      List
  3. 9 0
      README.md
  4. BIN
      main
  5. 35 0
      main.cpp

+ 1 - 1
CircleList.h

@@ -16,7 +16,6 @@ class CircleList: public List<T>
             Node<T>* currentNode = this->start;
             for(int i = 0; i < this->lenght; i++)
             {
-                std::cout << currentNode->value << std::endl;
                 currentNode = currentNode->next;
                 delete currentNode->prev;
             }
@@ -45,6 +44,7 @@ class CircleList: public List<T>
         }
 
         void pop(Node<T>* n) {
+            if (n == this->start) this->start = this->start->next; 
             this->List<int>::pop(n);
         }
 

+ 1 - 1
List

@@ -1 +1 @@
-Subproject commit c66dcff04935da1125502aaced81252f40b0701f
+Subproject commit b86e0339e4b79b439adef3cc983bf546b2464922

+ 9 - 0
README.md

@@ -0,0 +1,9 @@
+| N  | K  | Ответ  | Время  |
+| ------------ | ------------ | ------------ | ------------ |
+| 1000  | 3  | 601  |  0.000181 |
+| 5000  | 3  | 2861  | 0.000319  |
+| 10000  | 3  | 2689  | 0.000674  |
+| 50000  | 3  | 11744  | 0.001943  |
+| 100000  | 3  | 92617  | 0.00353 |
+| 500000  | 3  | 450130  | 0.020168 |
+| 1000000  | 3  | 637795  | 0.0527 |

BIN
main


+ 35 - 0
main.cpp

@@ -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);
 }