#include <stdio.h>
#include <string.h>
 

void bad_recursion_static(int* a, int n) {
  static int i = 0;
  if(i<n) {
    printf("%d ", a[i]);
    i++;
    bad_recursion_static(a, n);
  }
}


void print_rec(int* a, int n) {
  if (n==0)
    return;
  print_rec(a, n-1);      // recursively print a[0..n-2]
  printf("%d ", a[n-1]);  // print last element  
}

void print_rec2(int* a, int n) {
  if (n==0)
    return;
  printf("%d ", a[0]);  // print first element
  print_rec2(a+1, n-1);    // print the remaining a[1..n-1]  
}

int main(void) {
  int b[] = {1,2,3,4,5,6,7,8,9};
  printf("printing b:");
  bad_recursion_static(b,9);
  printf("\n");
  printf("printing b again:");
  bad_recursion_static(b,9);
  return 0;
}
