Esta es la contestación más acertada que te podemos dar, sin embargo mírala pausadamente y analiza si se puede adaptar a tu trabajo.
Ejemplo: ordenación por inserción en c
#include intmain()/* Here i & j for loop counters, temp for swapping,
* count for total number of elements, number[] to
* store the input numbers in array. You can increase
* or decrease the size of number array as per requirement
*/int i, j, count, temp, number[25];printf("How many numbers u are going to enter?: ");scanf("%d",&count);printf("Enter %d elements: ", count);// This loop would store the input numbers in arrayfor(i=0;i<count;i++)scanf("%d",&number[i]);// Implementation of insertion sort algorithmfor(i=1;i<count;i++)
temp=number[i];
j=i-1;while((temp<number[j])&&(j>=0))
number[j+1]=number[j];
j=j-1;
number[j+1]=temp;printf("Order of Sorted elements: ");for(i=0;i<count;i++)printf(" %d",number[i]);return0;
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)