Advertisement
ben1939

תרגיל 4 1

Nov 26th, 2013
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int multiply (int a, int b)
  4. {
  5.     if (b == 1) return a;
  6.     return a + multiply(a, b-1);
  7.  }
  8.  
  9.  
  10. int check(int i=1)
  11.  {
  12.     int a, b;
  13.     scanf("%d", &a);
  14.     if (a == 0)
  15.     return 0;
  16.  
  17.      b = check (i + 1);
  18.         if (i%2 == 0)  
  19.      return a+b;
  20.         else
  21.      return multiply (a,b);
  22. }
  23.  
  24. int add_or_multiply()
  25.  {
  26. return check();
  27.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement