ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo012.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Include dependency graph for Ejemplo012.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 5 of file Ejemplo012.c.

6{
7 int i, n;
8 float max, min, x;
9 srand(time(NULL));
10 do{
11 printf("Ingrese el numero de elementos: ");
12 scanf("%d", &n);
13 }while(n<1);
14 printf("Ingrese el valor maximo: ");
15 scanf("%f", &max);
16 printf("Ingrese el valor minimo: ");
17 scanf("%f", &min);
18 if(min>max)
19 {
20 if(max)
21 {
22 if(min)
23 {
24 min*=max;
25 max=min/max;
26 min/=max;
27 }
28 else
29 {
30 min = max;
31 max = 0;
32 }
33 }
34 else
35 {
36 max = min;
37 min = 0;
38 }
39 }
40 for(i=0; i<n; i++)
41 {
42 x = ((max-min)*rand())/RAND_MAX+min;
43 printf("%d. %f\n", i+1, x);
44 }
45 return 0;
46}
#define max
#define min