Skip to content

Instantly share code, notes, and snippets.

@pepet96
Created February 13, 2014 03:41
Show Gist options
  • Save pepet96/8969364 to your computer and use it in GitHub Desktop.
Save pepet96/8969364 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class largest1{
public static void main (String[] args)
{
Scanner input = new Scanner (System.in);
int params = input.nextInt();
int params1 = input.nextInt();
int[][] nums = new int[params][params1];
for (int i =0;i<nums.length;i++)
{
for (int j =0;j<nums[i].length;j++)
{
nums[i][j] = input.nextInt();
}
}
int largest = max(nums);
System.out.println(largest);
}
public static int max(int[][] nums)
{
Scanner input = new Scanner (System.in);
int max = nums[0][0];
int x =0;
int y=0;
for (int i= 0;i <nums.length;i++)
{
for (int j =0; j<nums[i].length;j++)
{
if (nums[i][j] > max)
{
max = nums[i][j];
x =i;
y =j;
}
}
}
int z = nums[x][y];
return z;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment