isama92

Minor Number Recursive

Nov 17th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1. class min_ricorsivo {
  2.     public static int min (int n, int i){
  3.         Display.print("Input " + i++ + " : ");
  4.         int r = Keyboard.readInteger();
  5.         if(n==0)
  6.             n=r;
  7.         if(r!=0){
  8.             if(r<n)
  9.                 n = r;
  10.             n = min(n, i);
  11.         }
  12.         return n;
  13.     }
  14.  
  15.     public static void main(String[] args){
  16.         int n = min(0, 1);
  17.         Display.println("Il numero minore e': " + n);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment