diff --git a/f1.c b/f1.c new file mode 100644 index 0000000..15c25f1 --- /dev/null +++ b/f1.c @@ -0,0 +1,96 @@ +#define _CRT_SECURE_NO_WARNINGS +#include +#include + +void f1(int n) { + printf("%d ", n); + if (n > 1) { + f1(n - 2); + } +} + +void f2(int n) { + printf("%d ", n); + if (n < 11) { + f2(n + 2); + } +} + +void f3(int n) { + printf("%d ", n); + if (n > 1) { + f3(n - 2); + } + printf("%d", n); +} + +void recEGE1(int n) { + if (n >= 1) { + printf(" %d", n); + recEGE1(n - 1); + recEGE1(n - 1); + } +} + +void ege2(int n) { + if (n > 2) { + printf("%d\n", n); + ege2(n - 3); + ege2(n - 4); + } +} + +void ege3(int n) { + if (n < 5) { + printf("%d\n", n); + ege3(n + 1); + ege3(n + 3); + } +} + +void g3(int n); + +void ege4(int n) { + if (n > 0) + g3(n - 1); +} + +void g3(int n) { + printf("*"); + if (n > 1) + ege4(n - 3); +} + +void zad9(int n) { + if (n > 0) { + printf("<"); + zad9(n - 1); + printf("%d", n); + printf(">"); + } +} + +void main() { + f1(11); + printf("\n"); + + f2(1); + printf("\n"); + + f3(11); + printf("\n"); + + recEGE1(3); + printf("\n"); + + ege2(10); + printf("\n"); + + ege3(1); + printf("\n"); + + f3(11); + printf("\n"); + + zad9(5); +} \ No newline at end of file diff --git a/fact.c b/fact.c new file mode 100644 index 0000000..1aef283 --- /dev/null +++ b/fact.c @@ -0,0 +1,18 @@ +//#define _CRT_SECURE_NO_WARNINGS +//#include +//#include +// +//long fact2(int n) { +// if (n == 0) { +// return 1; +// } +// long res = fact2(n - 1) * n; +// return res; +//} +// +//void main() { +// int n = 4; +// long f = fact2(n); +// +// printf("%d! = %ld", n, f); +//} \ No newline at end of file