[Show all top banners]
Back to: Kurakani General Refresh page to view new replies
 could anyone help with this problem please
[VIEWED 2974 TIMES]
SAVE! for ease of future access.
Posted on 06-28-10 7:20 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

could anyone help with this problem please

You are given three integer numbers: ab and c. Write a function:

int median3(int a,int b,int c);

which returns the second largest number x, among sequence (a,b,c).

For example:

  • for median3(4, 2, 6) the correct answer is 4,
  • for median3(1, 2, 2) the correct answer is 2.

 
Posted on 06-29-10 1:15 PM     [Snapshot: 176]     Reply [Subscribe]
Login in to Rate this Post:     1       ?     Liked by
 

what about this? ;-)

int median3(int a, int b, int c) {

int middle;

if(a < b && a > c || a > b && a < c){
middle = a;}
else if(b < a && b > c || b > a && b < c){
middle = b;}
else{middle = c;};

return middle;

}



 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 60 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
मन भित्र को पत्रै पत्र!
Guess how many vaccines a one year old baby is given
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
Why Americans reverse park?
They are openly permitting undocumented immigrants to participate in federal elections in Arizona now.
Driver license help ASAP sathiharu
whats wrong living with your parents ?
ढ्याउ गर्दा दसैँको खसी गनाउच
TPS Reregistration and EAD Approval Timeline.......
lost $3500 on penny stocks !!!
nrn citizenship
Elderly parents travelling to US (any suggestions besides Special Assistance)?
कल्लाई मुर्ख भन्या ?
जाडो, बा र म……
Changing job after i-140 approval
Is this a progressive step?
Nepalese Students Face Deportation over Pro-Palestine Protest
Trasiting through Istanbul, Turkey
Nepali **fake** Veterans. Be aware!!
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters