/* Algorithm: Insert Sort
* ACM edition
* sort M number
*/ #include<stdio.h>
#define M 10
void insort(int A[],int n) { int i=2,j;
for(i=2;i<n;i++) {
A[0]=A[i];
j=i-1; while(A[0]<A[j]) {
A[j+1]=A[j];/* move back A[j] */
j--; }/* Find the 1st number which is little than A[i]
then,insert A[0] */
A[j+1]=A[0]; } }
int main(int argc,char**argv) { int r[M+1]; int i;
/* Algorithm: Inert Sort
* My edition
* sort M number
*/ #include<stdio.h>
#define M 10
void insort(int A[],int n) { int i,j; int r;
for(i=1;i<n;i++) {
r=A[i]; for(j=i-1;j>=-1;j--) {/* Find the 1st number which is little than A[i]
then,insert r(A[i]) and break */ if(A[j]<=r || j==-1){
A[j+1]=r; break; } elseif(A[j]>r)
A[j+1]=A[j];/* move back A[j] */ } } }