diff options
Diffstat (limited to '21_read_rec1/test.c')
-rw-r--r-- | 21_read_rec1/test.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/21_read_rec1/test.c b/21_read_rec1/test.c new file mode 100644 index 0000000..52fd4e4 --- /dev/null +++ b/21_read_rec1/test.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> + +void printDigits(int x) { + if (x == 0) { + printf("0"); + } + else if (x < 0) { + printf("-"); + printDigits(-x); + } + else { + int a = x/10; + int b = x %10; + printf("a=%d, b=%d\n",a,b); + if (a != 0) { + printDigits(a); + } + printf("%d",b); + } +} + + +int main(void) { + printDigits(297); + printf("\n"); + return EXIT_SUCCESS; +} |