Insertion sort ...... Selection sort...... Bubble sort...... Recursive...... Doubly linked list...... Sort more then to Least By Linked List...... Average By Linked list...... Singly Linked List...... Circular Queue...... Perfectly Queue...... Evaluate by Stack...... postfix to infix...... infix To postfix...... stack And queue

Oracle and Java Blog

Mobile Embedded Features

java.net Forums: Message List - Java Web Services and XML

java.net's Javapedia web

Thursday, May 10, 2007

Insertion sort

#include
#include
#include

#define max 10

void print_array(int *array) {
int x;
for(x = 0; x if(x != max-1)
printf("%d, ", array[x]);
else
printf("%d\n", array[x]);
}
}
void main(){
int iarray[max];
int i,j;
int k;
// Seed rand()
srand((unsigned int)time(NULL));

for(i = 0; i < max; i++)
iarray[i] = (int)(rand() % 100);
// print initial data
printf("initial data \n");
print_array(iarray);
printf("\n");
//insertion sort
for(i=0 ; i k=iarray[i];
for(j=i-1;i>0 && k iarray[j+1] = iarray[j];
iarray[j] = k;
}
printf("round %d\n",i);
print_array(iarray);
}
printf("result sort\n");
print_array(iarray);
}

No comments: