Ayuda con este programa
Publicado por Enrique Mateos (1 intervención) el 24/09/2013 01:15:40
Alguien podria ayudarme con este programa, ya compile en Dev C++ y esta todo perfecto, el problema es que cuando lo corro, pongo un numero cualquiera, excepto el 0, me dice error al cargar... ayuda porfa!! :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# include <stdio.h>
# include <stdlib.h>
# include <conio.h>
# include <math.h>
// macros o constantes
# define continuar printf (" \n teclee <enter> para continuar... "); getche( );
// seccion de funciones
int datos(int *t)
{
printf ("ingrese tiempo de simulacion: ");
scanf ("%d", t );
*t= abs(*t);
}
int simulacion (int t, float *profesional, float *prepa)
{
profesional=(float *)malloc (sizeof(float)*t);
prepa=(float *)malloc (sizeof(float)*t);
for(int i=0; i<t ; i++)
{
*(profesional + i)= 1.0 - exp ((-i/5.0) * log (0.5));
*(prepa + 1)= 1.0 - exp ((-i/9.0) * log (0.5));
}
}
int resultados (int t,float *profesional,float *prepa)
{
int i;
printf ("profesional..." );
for (i=0; i<t; i++)
printf (" %f", * (profesional + i));
printf (" \n prepa...");
for (i=0; i<t; i++)
printf ("%f", *(prepa + i));
}
int salir (int * ok)
{
int temp;
printf ("Menu: ");
printf ("1.- continuar");
printf ("2.- continuar");
printf ("opcion: ");
scanf ("%d", & temp);
if (temp !=1)
*ok = 1;
}
int main ( )
{
int t, ok = 0;
float * profesional, * prepa;
2
while (!ok)
{
datos (&t);
simulacion (t, profesional, prepa);
resultados (t, profesional, prepa);
salir (& ok);
}
}
Valora esta pregunta


0