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

Mobile Embedded Features

Error loading feed.

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

Error loading feed.

java.net's Javapedia web

Error loading feed.

Thursday, May 10, 2007

Selection 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 temp;
int min;
// Seed rand()
srand((unsigned int)time(NULL));

for(i = 0; i < max; i++)
iarray[i] = (int)(rand() % 100);

//selection sort
for(i=0 ; i printf("round %d\n",i);
print_array(iarray);
min = i;
for(j=i+1;j if(iarray[j] min = j;
temp = iarray[i];
iarray[i] = iarray[min];
iarray[min]=temp;
}
printf("result sort\n");
print_array(iarray);
}

No comments: