From feda98d7c7fc0771e3f143932d5184ab128dea92 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 6 Feb 2023 18:12:15 +0100 Subject: WIP algo week 2 --- algo1w2/main.c | 26 ++++++++++++++++++++++++++ algo1w2/makefile | 1 + week.mk | 17 ++++++++++++----- 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 algo1w2/main.c create mode 120000 algo1w2/makefile diff --git a/algo1w2/main.c b/algo1w2/main.c new file mode 100644 index 0000000..4bc6c46 --- /dev/null +++ b/algo1w2/main.c @@ -0,0 +1,26 @@ +#include + +void bubble_sort(int* arr, unsigned size) { + int outer, inner; + bool sorted = false; +} + +void print_arr(int* arr, unsigned size) { + printf("["); + for (unsigned i = 0; i < size; i++) { + if (i > 0) printf(", "); + printf("%d", arr[i]); + } + printf("]\n"); +} + +int main() { + int arr[] = { 7, 3, 8, 1, 2, 5, 4, 6, 9, 0 }; + unsigned size = sizeof(arr) / sizeof(int); + + print_arr(arr, size); + bubble_sort(arr, size); + print_arr(arr, size); + + return 0; +} diff --git a/algo1w2/makefile b/algo1w2/makefile new file mode 120000 index 0000000..a4e84c6 --- /dev/null +++ b/algo1w2/makefile @@ -0,0 +1 @@ +../week.mk \ No newline at end of file diff --git a/week.mk b/week.mk index 7a58f4d..c414a31 100644 --- a/week.mk +++ b/week.mk @@ -1,21 +1,28 @@ -CC = g++ +CPP = g++ LD = g++ +CC = gcc RM = rm -f TARGET = main OUTPUT_ZIP = Huiswerk_2180996.zip LFLAGS += -lstdc++ -SRCS := $(wildcard *.cpp) -OBJS := $(patsubst %.cpp,%.o, $(SRCS)) +SRCS += $(wildcard *.cpp) +SRCS += $(wildcard *.c) +OBJS := $(SRCS) +OBJS := $(patsubst %.cpp,%.o, $(OBJS)) +OBJS := $(patsubst %.c,%.o, $(OBJS)) .PHONY: clean compile_commands zip all: $(TARGET) -%.o: %.cpp +%.o: %.c $(CC) -c $(CFLAGS) $< -o $@ +%.o: %.cpp + $(CPP) -c $(CFLAGS) $< -o $@ + $(TARGET): $(OBJS) $(LD) $^ $(LFLAGS) -o $@ @@ -26,5 +33,5 @@ compile_commands: clean compiledb make -Bn zip: all - zip -q $(OUTPUT_ZIP) makefile $(wildcard *.cpp) $(wildcard *.h) $(wildcard *.hpp) + zip -q $(OUTPUT_ZIP) makefile $(wildcard *.cpp) $(wildcard *.h) $(wildcard *.hpp) $(wildcard *.c) $(wildcard *.svg) -- cgit v1.2.3