Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

sort 3 numbers using swap cpp

if (a > c)
   swap(a, c);

if (a > b)
   swap(a, b);

//Now the smallest element is the 1st one. Just check the 2nd and 3rd

if (b > c)
   swap(b, c);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #numbers #swap #cpp
ADD COMMENT
Topic
Name
5+9 =