diff --git a/Makefile b/Makefile index be89a08..bf71fca 100755 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CC := clang++ -Wall -std=c++17 -Wall -Wextra -O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer +CC := clang++ -Wall -std=c++17 -Wall -Wextra -g -fsanitize=address,undefined -fno-omit-frame-pointer setup: mkdir build @@ -34,6 +34,11 @@ sheet05: chmod +x build/sheet05 build/sheet05 +sheet06: + $(CC) src/sheet06.cpp -o build/sheet06 + chmod +x build/sheet06 + build/sheet06 + pizza: $(CC) src/pizza.cpp -o build/pizza chmod +x build/pizza diff --git a/src/sheet04.cpp b/src/sheet04.cpp index d2ca5ae..2b7e6cd 100755 --- a/src/sheet04.cpp +++ b/src/sheet04.cpp @@ -211,7 +211,7 @@ class vec int main() { std::string ans; - std::cout << "y for vector exercies: "; + std::cout << "y for vector exercises: "; std::cin >> ans; if(ans == "y") { diff --git a/src/sheet05.cpp b/src/sheet05.cpp index a4e5f5a..7a679e9 100755 --- a/src/sheet05.cpp +++ b/src/sheet05.cpp @@ -126,25 +126,19 @@ struct Node { void addElement(Node **head, int data) { - if(*head == nullptr) - { - *head = new Node(data); - return; - } + Node **og_head = head; - Node **next = &(**head).next; - do + while(*head != nullptr) { - *next = (**next).next; + head = &(**head).next; } - while(*next != nullptr) - *next = new Node(data); + *head = new Node(data); + head = og_head; } void printList(const Node *head) { std::cout << *head << '\n'; Node *next = (*head).next; - std::cout << (next != nullptr) << '\n'; while(next != nullptr) { std::cout << *next << '\n'; diff --git a/src/sheet06.cpp b/src/sheet06.cpp new file mode 100644 index 0000000..74a4df9 --- /dev/null +++ b/src/sheet06.cpp @@ -0,0 +1,10 @@ +#include +#define MY_ASSERT(BOOL_EXPR, MESSAGE) +{ + if (!BOOL_EXPR) + { + std::cout << MESSAGE << '\n'; + std::cout << __FILE__ << '\n'; + std::cout << __LINE__ << '\n' + } +} \ No newline at end of file diff --git a/vgcore.13380 b/vgcore.13380 new file mode 100644 index 0000000..16a6e58 Binary files /dev/null and b/vgcore.13380 differ