Created
September 23, 2012 11:43
-
-
Save mgronhol/3769937 to your computer and use it in GitHub Desktop.
Sort three entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Sorttaa { | |
| public static int sorttaa( int a, int b, int c, int monesko ){ | |
| int tmp; | |
| if ( a > b ){ | |
| tmp = b; | |
| b = a; | |
| a = tmp; | |
| } | |
| if( a > c ){ | |
| tmp = c; | |
| c = a; | |
| a = tmp; | |
| } | |
| if( b > c ){ | |
| tmp = c; | |
| c = b; | |
| b = tmp; | |
| } | |
| switch( monesko ){ | |
| case 1: | |
| tmp = a; | |
| break; | |
| case 2: | |
| tmp = b; | |
| break; | |
| case 3: | |
| tmp = c; | |
| break; | |
| default: tmp = c; | |
| } | |
| return tmp; | |
| } | |
| public static void main( String[] args ){ | |
| System.out.println( sorttaa( 3, 2, 1, 1 ) ); | |
| System.out.println( sorttaa( 3, 2, 1, 2 ) ); | |
| System.out.println( sorttaa( 3, 2, 1, 3 ) ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment