#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Go to the source code of this file.
|
| int | main (int argc, char *argv[]) |
◆ main()
| int main |
( |
int | argc, |
|
|
char * | argv[] ) |
Definition at line 7 of file 017_Insercion.c.
8{
9 long int n, i, j;
11 srand(time(NULL));
12 do{
13 printf("Ingrese el numero de elementos: ");
14 scanf("%ld", &n);
16 printf("Ingrese le valor maximo: ");
18 printf("Ingrese el valor minimo: ");
21 {
25 }
26 printf(
"[%f, %f]\n",
min,
max);
27 printf("Desordenados.\n");
28 for(i=0; i<n; i++)
29 {
31 printf("X[%ld] = %f\n", i+1, X[i]);
32 }
33 for(i=1; i<n; i++)
34 {
35 aux = X[i];
36 j = i-1;
37 while(X[j]>aux)
38 {
39 X[j+1] = X[j];
40 j--;
41 if(j<0)
42 break;
43 }
44 X[j+1]=aux;
45 }
46
47 printf("Ordenados.\n");
48 for(i=0; i<n; i++)
49 printf("X[%ld] = %f\n", i+1, X[i]);
50 return 0;
51}