Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public class Tests {
  2.  
  3.     public static void main(String[] args) {
  4.         int[] nums = new int[] {10,32,40,43,21,35,37,9,23};
  5.         getSmallest(nums, 1, 5);
  6.        
  7.         System.out.println(getSmallest(nums, 3, 7) + "hello");
  8.         System.out.println(nums[0]);
  9.        
  10.     }
  11.  
  12.     private static int getSmallest(int[] nums, int first, int end) {
  13.  
  14.  
  15.               if (end == nums.length - 1) {
  16.                 return nums[end];
  17.               }
  18.  
  19.               int val = min(nums, end + 1);
  20.  
  21.               if (nums[end] < val)
  22.                 return nums[end];
  23.               else
  24.                 return getSmallest(nums, first, end);
  25.             }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement