#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 Ejemplo016.c.
8{
9 int i, j, k, n;
11 srand(time(NULL));
12 do{
13 printf("Ingrese el numero de elementos: ");
14 scanf("%d", &n);
16 printf("Ingrese el valor maximo: ");
18 printf("Ingrese el valor minimo: ");
21 {
23 {
25 {
29 }
30 else
31 {
34 }
35 }
36 else
37 {
40 }
41 }
42 printf("Desordenado.\n");
43 for(i=0; i<n; i++)
44 {
46 printf("X[%d] = %f\n", i+1, x[i]);
47 }
48
49 for(i=1; i<n; i++)
50 {
51 aux = x[i];
52 j=i-1;
53 while(aux<x[j])
54 {
55 x[j+1] = x[j];
56 j--;
57 if(j<0)
58 break;
59 }
60 x[j+1] = aux;
61 }
62 printf("Ordenado.\n");
63 for(i=0; i<n; i++)
64 printf("X[%d] = %f\n", i+1, x[i]);
65 return 0;
66}