Two-bit array-select sort

Source: Internet
Author: User

#include <stdio.h>intMain () {inti,j; inta[Ten]; intiTemp; intIPos; printf ("assign value to an array element: \ n"); //Assigning a value to an array by using the keyboard     for(i=0;i<Ten; i++) {printf ("a[%d]=", i); scanf ("%d",&A[i]); }    //start sorting core programs from small to large     for(i=0;i<9; i++)//0 1 2 3 4 5 6 7 8 9 cycles Outer Loop{iTemp=A[i]; IPos=i;  for(j=i+1;j<Ten; j + +)//j = 1 2 3 4 5 6 7 8 9 9 Cycles        {            if(a[j]<iTemp) {ITemp=A[j]; IPos=J; }        }    }    //Exchange values for two elementsa[ipos]=A[i]; A[i]=iTemp; //Output Array     for(i=0;i<Ten; i++) {printf ("%d\t", A[i]); if(i==4) printf ("\ n"); }    return 0 ;} Operation results This sort method has a problem with big numbers, but I don't understand this sort of algorithm ... [Email protected]:~/cprogram#./x Selection method ordering. outAssigning a value to an array element: a[0]=1123a[1]=123a[2]=123a[3]= -a[4]= Aa[5]= toa[6]= ata[7]= +a[8]=3213a[9]= A1123    123    123     -     A     to     at     +    3213     A[e-mail protected]:~/cprogram#./x Select to sort by.] outAssigning a value to an array element: a[0]=1a[1]=2a[2]=3a[3]=4a[4]=5a[5]=6a[6]=7a[7]=8a[8]=9a[9]=01    2    3    4    5    6    7    8    9    0[Email protected]:~/cprogram#

Two-bit array-select sort

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.