Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sum(int arr[],int size){
- //caso base
- if(size==0)
- return 0;
- else
- //passo ricorsivo, somma l'elemento e rifai la stessa cosa per il successivo
- //il passo ricorsivo considera come elemento attuale quello in posizione -1, quindi alla
- //fine verra' sommato anche l'elemento in posizione 0.
- return sum(arr,size-1) + arr[size-1];
- }
Advertisement
Add Comment
Please, Sign In to add comment