Welcome, %1$s. Please login or register.

November 22, 2017, 08:28:26 PM
: 1
: Single line code..  ( 3138 )
« : September 07, 2007, 11:00:58 AM From Sudeep»



Single line code..


Given... the nos... 19,7,4. let them be any integers a,b,c.

print the numbers in ascending order.

CONDITION:  the solution should be a single line code

 
Liked It? Share it!

              


« #1 : September 07, 2007, 11:06:24 AM From satyadb4u»

you mean to say the numbers are constant that is only for the case of numbers you given
« #2 : September 07, 2007, 12:21:40 PM From Sudeep»

Sorry.. please consider the modification in code.... :P
« #3 : September 07, 2007, 11:14:11 PM From Poonam»


return a > b ? ( a > c ? a : c ) : ( b > c ? b : c );
« #4 : September 10, 2007, 05:12:52 PM From Sudeep»

@guru
i want it printed guys. all of them in ascending order. not the largest no...???
« #5 : September 10, 2007, 10:26:04 PM From Poonam»

printf("%d, %d, %d\n",
        a > b ? ( a > c ? a : c ) : ( b > c ? b : c ),
        a > b ? ( a > c ? c : a ) : ( b > c ? c : b ),
        a < b ? ( a < c ? a : c ) : ( b < c ? b : c ));
« #6 : September 10, 2007, 10:39:16 PM From spazinvader»

A little change guru.
He asked it in ascending order.But u have done it in descending order.
So it should be
printf("%d, %d, %d\n",
        a < b ? ( a < c ? a : c ) : ( b < c ? b : c ),
        a > b ? ( a > c ? c : a ) : ( b > c ? c : b ),
        a > b ? ( a > c ? a : c ) : ( b > c ? b : c ));

« #7 : September 10, 2007, 10:43:35 PM From Poonam»

Thanks for the correction, Spazinvader  ;)
: 1
« previous next »

 

Best RatedList All>>



Latest
Random



SMF 2.0.10 | SMF © 2015, Simple Machines | Contact Webmaster | OnlineFunDb.com © 2009/10 | Legal Disclaimer