This commit is contained in:
Johannes Theiner 2018-03-12 22:29:27 +01:00
parent cf4270554f
commit 974ccc9f27
6 changed files with 31 additions and 9 deletions

Binary file not shown.

View File

@ -1,3 +1,3 @@
bash clean.sh 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 clang-6.0 -s func1.o main.o

View File

@ -1,6 +1,10 @@
#include <stdio.h>
#include <math.h>
#define func1 #define func1
int func3(int x) { int func3(int x) {
//return pow(x, 3) - 3 * pow(x, 2) - x + 3;
return x + 10; return x + 10;
} }
@ -9,10 +13,16 @@ int func2(int x) {
} }
int recurse1(int count) { int recurse1(int count) {
return func1(count - 1); 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;
} }

Binary file not shown.

View File

@ -27,16 +27,28 @@ int main(int argc, char **argv) {
printf("For: %d\n", tmp); printf("For: %d\n", tmp);
int temp = 0; tmp = 0;
int j = 0; int j = 0;
while(j <= 5) { while(j <= 5) {
temp += func3(j); tmp += func3(j);
++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); local = sum(global, local);
return local; return local;

Binary file not shown.