• Post Reply Bookmark Topic Watch Topic
  • New Topic

Find largest element in multidimensional array and print location  RSS feed

 
jimmy dean
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey are you good enough to do this?

(Locating the largest element) Write the following method that returns the location of the largest element in a two-dimensional array.

public static int[] locateLargest(double[][] a)

The return value is a one-dimensional array that contains two elements. These two elements indicate the row and column indices of the largest element in the two dimensional array. Write a test program that prompts the user to enter a two-dimensional array and displays the location of the largest element in the array. Here is a sample run:

Enter the number of rows and columns of the array: 3 4
Enter the array:
23.5 35 2 10
4.5 3 45 3.5
35 44 5.5 9.6
The location of the largest element is at (1, 2)

Best answer gets secret prize

 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I smell homework. Nice try.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree that it smells like homework. And even if it isn't, it's not really a challenge to solve this.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I am not convinced this is a "diversion" but normal programming, so I shall move you to another location.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!