This commit is contained in:
Leon Wilzer 2022-12-15 12:40:36 +01:00
parent d1ba83064a
commit 49166965ff
5 changed files with 22 additions and 13 deletions

View File

@ -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: setup:
mkdir build mkdir build
@ -34,6 +34,11 @@ sheet05:
chmod +x build/sheet05 chmod +x build/sheet05
build/sheet05 build/sheet05
sheet06:
$(CC) src/sheet06.cpp -o build/sheet06
chmod +x build/sheet06
build/sheet06
pizza: pizza:
$(CC) src/pizza.cpp -o build/pizza $(CC) src/pizza.cpp -o build/pizza
chmod +x build/pizza chmod +x build/pizza

View File

@ -211,7 +211,7 @@ class vec
int main() int main()
{ {
std::string ans; std::string ans;
std::cout << "y for vector exercies: "; std::cout << "y for vector exercises: ";
std::cin >> ans; std::cin >> ans;
if(ans == "y") if(ans == "y")
{ {

View File

@ -126,25 +126,19 @@ struct Node {
void addElement(Node **head, int data) void addElement(Node **head, int data)
{ {
if(*head == nullptr) Node **og_head = head;
{
*head = new Node(data);
return;
}
Node **next = &(**head).next; while(*head != nullptr)
do
{ {
*next = (**next).next; head = &(**head).next;
} }
while(*next != nullptr) *head = new Node(data);
*next = new Node(data); head = og_head;
} }
void printList(const Node *head) void printList(const Node *head)
{ {
std::cout << *head << '\n'; std::cout << *head << '\n';
Node *next = (*head).next; Node *next = (*head).next;
std::cout << (next != nullptr) << '\n';
while(next != nullptr) while(next != nullptr)
{ {
std::cout << *next << '\n'; std::cout << *next << '\n';

10
src/sheet06.cpp Normal file
View File

@ -0,0 +1,10 @@
#include<iostream>
#define MY_ASSERT(BOOL_EXPR, MESSAGE)
{
if (!BOOL_EXPR)
{
std::cout << MESSAGE << '\n';
std::cout << __FILE__ << '\n';
std::cout << __LINE__ << '\n'
}
}

BIN
vgcore.13380 Normal file

Binary file not shown.