C_CPP/01_ENV/func1.c

27 lines
514 B
C
Raw Normal View History

2018-03-12 22:29:27 +01:00
#include <stdio.h>
2018-03-12 22:51:08 +01:00
#include <math.h>
2018-03-12 22:29:27 +01:00
2018-03-12 15:20:16 +01:00
#define func1
2018-03-12 21:11:29 +01:00
int func3(int x) {
2018-03-12 22:36:48 +01:00
return pow(x, 3) - 3 * pow(x, 2) - x + 3;
2018-03-12 15:20:16 +01:00
}
2018-03-12 21:11:29 +01:00
int func2(int x) {
2018-03-12 23:17:36 +01:00
return pow(x, 4) - 5 * pow(x, 3) + pow(x, 2) + 5;
2018-03-12 21:11:29 +01:00
}
2018-03-12 22:29:27 +01:00
int recurse1(int count) {
if(count >= 0) {
2018-03-12 23:17:36 +01:00
printf("Recurse 1: %d", func3(count - 1));
2018-03-12 22:29:27 +01:00
return recurse1(count - 1);
}else return 0;
2018-03-12 21:11:29 +01:00
}
2018-03-12 22:29:27 +01:00
int recurse2(int count) {
if(count >= 0) {
2018-03-12 23:17:36 +01:00
printf("Recurse 2: %d", func3(count - 1));
2018-03-12 22:29:27 +01:00
return recurse1(count - 1);
}else return 0;
2018-03-12 22:36:48 +01:00
}