diff --git a/01_ENV/a.out b/01_ENV/a.out index 72d69b6..63075a8 100755 Binary files a/01_ENV/a.out and b/01_ENV/a.out differ diff --git a/01_ENV/build-c.sh b/01_ENV/build-c.sh index d48a80e..218240c 100755 --- a/01_ENV/build-c.sh +++ b/01_ENV/build-c.sh @@ -1,3 +1,3 @@ bash clean.sh -clang-6.0 -c func1.c main.c +clang-6.0 -c func1.c main.c -lm clang-6.0 -s func1.o main.o diff --git a/01_ENV/func1.c b/01_ENV/func1.c index 29d68a5..fb45c6a 100644 --- a/01_ENV/func1.c +++ b/01_ENV/func1.c @@ -1,6 +1,10 @@ +#include +#include + #define func1 int func3(int x) { + //return pow(x, 3) - 3 * pow(x, 2) - x + 3; return x + 10; } @@ -8,11 +12,17 @@ int func2(int x) { return x - 10; } -int recurse1(int count) { - return func1(count - 1); +int recurse1(int count) { + if(count >= 0) { + printf("Recurse 1: %d\n", func3(count - 1)); + return recurse1(count - 1); + }else return 0; } -int recurse2(int x) { - +int recurse2(int count) { + if(count >= 0) { + printf("Recurse 2: %d\n", func3(count - 1)); + return recurse1(count - 1); + }else return 0; } diff --git a/01_ENV/func1.o b/01_ENV/func1.o index c3f3edf..3a13b68 100644 Binary files a/01_ENV/func1.o and b/01_ENV/func1.o differ diff --git a/01_ENV/main.c b/01_ENV/main.c index 4fc4ca5..5ed484e 100644 --- a/01_ENV/main.c +++ b/01_ENV/main.c @@ -27,16 +27,28 @@ int main(int argc, char **argv) { printf("For: %d\n", tmp); - int temp = 0; + tmp = 0; int j = 0; while(j <= 5) { - temp += func3(j); + tmp += func3(j); ++j; } - printf("While: %d\n", temp); + + printf("While: %d\n", tmp); - printf("Recurse 1: %d\n", recurse1(2)); + tmp = 0; + int zeroes = 0; + for(int i = 0; i <= 5; ++i) { + int func = func3(i); + tmp += func; + if(tmp == 0) zeroes++; + } + printf("Nullstellen: %d\n", zeroes); + + + recurse1(20); + recurse2(20); local = sum(global, local); return local; diff --git a/01_ENV/main.o b/01_ENV/main.o index 36ff3a5..03be1ba 100644 Binary files a/01_ENV/main.o and b/01_ENV/main.o differ