Guest User

Untitled

a guest
Jan 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* 請不要使用 for, 而用遞迴改寫這個函式 */
  5. int sumArray(int array[], int size)
  6. {
  7. int i, sum = 0;
  8. for (i = 0; i < size; i++)
  9. sum += array[i];
  10. return sum;
  11. }
  12.  
  13. int main( void )
  14. {
  15. int array[] = {1, 2, 3, 4, 5};
  16. printf("sum of array = %d\n", sumArray(array, 5));
  17. }
Add Comment
Please, Sign In to add comment