Created
August 6, 2015 19:35
-
-
Save StefanoFiumara/626cb12283ab91e52b12 to your computer and use it in GitHub Desktop.
This file contains 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
void Main() | |
{ | |
int[][] arguments = new int[][] | |
{ | |
new int[] {4,5,1,3}, | |
new int[] {13,27,18,26}, | |
new int[] {32,35,37,39}, | |
new int[] {1000, 1001, 857,1} | |
}; | |
int[] result = LargestOfFour( arguments ); | |
Console.WriteLine(result); | |
} | |
// Define other methods and classes here | |
int[] LargestOfFour(int[][] lists) | |
{ | |
int[] largestValues = new int[ lists.Length ]; | |
for(int i = 0; i < lists.Length; i++) | |
{ | |
int[] currentList = lists[i]; | |
int currentLargest = GetLargestValue( currentList ); | |
largestValues[i] = currentLargest; | |
} | |
return largestValues; | |
} | |
int GetLargestValue(int[] list) | |
{ | |
int largestValue = int.MinValue; | |
for(int i = 0; i < list.Length; i++) | |
{ | |
if(list[i] > largestValue) | |
{ | |
largestValue = list[i]; | |
} | |
} | |
return largestValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment