SHARE
TWEET

Untitled

a guest Apr 26th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class AltifLiad {
  3.  
  4.     public static void main(String[] args) {
  5.         int [] arr;
  6.         arr = new int [5];
  7.         arr[0]=5;
  8.         arr[1]=3;
  9.         arr[2]=7;
  10.         arr[3]=6;
  11.         arr[4]=15;
  12.         int index=2;
  13.         System.out.println(mone(arr,index));
  14.         System.out.println(mone2(arr));
  15.     }
  16.     public static int mone(int[]arr,int index)
  17.     {
  18.         if(index==arr.length)
  19.             return 0;
  20.         return mone(arr,index+1)+arr[index];
  21.        
  22.     }
  23.     public static int mone2(int[]arr)
  24.     {
  25.         return mone(arr,0);
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top