Java Learning Digital Sorting order

Source: Internet
Author: User

The first time to learn Java, the following case only discusses the input three number of sequential order size, the idea is to first enter a number and to, split open, through the nextline to get the string just entered, and by splitting up a string array, Converts a string array to an int array , Arr[i]=integer.parseint (S[i]), using a for array; then, according to the initial value assigned to Max,min,mid, the output of its minimum, median, and maximum values are judged respectively.

Import Java.util.scanner;class bigger {public static void main (string[] args) {Scanner scan=new Scanner (system.in); String A=scan.nextline (); String[] S=a.split (","); int[] arr=new int[s.length];for (int i=0;i<s.length;i++) {arr[i]=integer.parseint (s[i]);} int max=arr[0];int min=arr[0];int mid=arr[0];for (int i=0;i<arr.length; i++) {if (Max<=arr[i]) {max=arr[i];} else if (min>=arr.length) {min=arr[i];} Else{mid=arr[i];}} System.out.println (min+ "   " +mid+ ""   +max);}}

  

Java Learning Digital Sorting order

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.