Created
          January 31, 2014 15:06 
        
      - 
      
- 
        Save pepet96/8733753 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.util.Scanner; | |
| public class largest { | |
| public static void main (String [] args) { | |
| Scanner input = new Scanner(System.in); | |
| int positions = input.nextInt(); | |
| int[] myArray = new int[positions]; | |
| for (int i = 0; i < myArray.length; i++){ | |
| myArray[i] = input.nextInt(); | |
| } | |
| int greatestvalue = maxTriple(myArray); | |
| System.out.println(greatestvalue); | |
| } | |
| public static int maxTriple (int [] myArray){ | |
| int a = myArray[0]; | |
| int c = myArray[myArray.length - 1]; | |
| int b = myArray[(myArray.length/2)+1]; | |
| int greater = 0; | |
| if ( a > b && a > c){ | |
| greater = a; | |
| } | |
| else if ( b > a && b > c){ | |
| greater = b; | |
| } | |
| else if ( c > a && c > b){ | |
| greater = c; | |
| } | |
| return greater; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment