(5) input three integers using command line parameters and sort the three numbers in descending order

Source: Internet
Author: User

 1   /*  Use the command line parameter to input three integers and sort the three numbers in descending order.  2   -PS: convert a string to a number.  3   • Int num = integer. parseint (string number );  */  4   Package  Com. gen;  5   6  Public   Class  Argumentorder {  7       Public   Static   Void  Main (string ARGs [])  8   {  9 System. Out. println ("Please input three number by ARGs :" );  10           Int Num [] = New  Int [3 ];  11           12           For ( Int I = 0; I <3; I ++ )  13   {  14 Num [I] = Integer. parseint (ARGs [I]);  15   }  16   Sort (Num ); 17           For ( Int J = 0; j <3; j ++ )  18   {  19   System. Out. println (Num [J]);  20   }  21          22   }  23       Static   Void Sort (Int  Num [])  24   {  25           26        For ( Int I = 0; I <num. length; I ++ )  27   {  28              For ( Int J = I + 1; j <num. length; j ++ )  29  {  30                   If (Num [I] < Num [J])  31   {  32                      Int Temp = Num [J];  33 Num [J] = Num [I];  34 Num [I] = Temp;  35   } 36   }  37   }  38   }  39   }  40 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.