Simple sort of selection

Source: Internet
Author: User

1  PackageCom.hp.io;2 3 ImportJava.util.Scanner;4 5  Public classXuanze {6      Public Static voidMain (string[] args) {7Scanner s =NewScanner (system.in);8System.out.println ("Please enter the number of arrays");9         intA =s.nextint ();Ten         int[] B =New int[a]; OneSystem.out.println ("Elements in the input array:"); A          for(inti = 0; i < b.length; i++{//The elements in the array are traversed after the operation -B[i] =s.nextint (); -         } the          for(inti = 0; i < b.length-1; i++) { -              for(intj = i + 1; J < B.length; J + +) { -                 if(B[i] >B[j]) { -                     inttemp =B[i]; +B[i] =B[j]; -B[J] =temp; +                 } A             } at         } -          for(intk = 0; K < B.length; k++) { -System.out.println (B[k] + ""); -         } -     } -}


1  PackageCom.hp.io;2 3 ImportJava.util.Scanner;4 5  Public classMaopao {6      Public Static voidMain (string[] args) {7Scanner s =NewScanner (system.in);8System.out.println ("Please enter the number of arrays");9         intA =s.nextint ();Ten         int[] B =New int[a]; OneSystem.out.println ("Elements in the input array:");//traversing elements in an array A          for(inti = 0; i < b.length; i++) { -B[i] = S.nextint ();//the element of array B is the element of the input -         } the          for(inti = 0; i < b.length-1; i++) { -              for(intj = i + 1; J < B.length; J + +) { -                 if(B[i] >B[j]) { -                     inttemp =B[i]; +B[i] =B[j]; -B[J] =temp; +                 } A             } at         } -          for(intk = 0; K < B.length; k++) {//The array is also required to traverse when printing -System.out.println (B[k] + ""); -         } -     }

Simple sort of selection

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.