summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-02-06 18:12:15 +0100
committerlonkaars <loek@pipeframe.xyz>2023-02-06 18:12:15 +0100
commitfeda98d7c7fc0771e3f143932d5184ab128dea92 (patch)
tree5552b70a67ae4a428e5856cb6b7576dc3c1394ad
parentd069d90980d9bf0af1f414c4f7584295dca50c44 (diff)
WIP algo week 2
-rw-r--r--algo1w2/main.c26
l---------algo1w2/makefile1
-rw-r--r--week.mk17
3 files changed, 39 insertions, 5 deletions
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 <stdio.h>
+
+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)