944,156 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1457
  • Java RSS
Oct 12th, 2007
0

JAVA Expert Help me.. Write a function that accepts an array of integers and returns

Expand Post »
Write a function that accepts an array of integers and returns the second largest integer in the array. Return -1 if there is no second largest.

The signature of the function is

public class bc
{
public static void main(String[] args){ }
int f(int[ ] a) { }

}

Examples:

if the input array is {1, 2, 3, 4} return 3
if the input array is {{4, 1, 2, 3}} return 3
if the input array is {1, 1, 2, 2} return 1
if the input array is {1, 1} return -1
if the input array is {1} return -1
if the input array is {} return -1


bc.java (Required code)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bc030400412 is offline Offline
5 posts
since Oct 2007
Oct 12th, 2007
0

Re: JAVA Expert Help me.. Write a function that accepts an array of integers and returns

Just post your code and ask about the parts you don't understand. All you have posted here is your assignment.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: How to Find the Latitude and Longitude values from the Google Maps
Next Thread in Java Forum Timeline: Java JButton problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC