Dev - C++ - Ayuda con algoritmo

 
Vista:
sin imagen de perfil

Ayuda con algoritmo

Publicado por gustavo (3 intervenciones) el 17/11/2015 00:17:31
Buenas tardes, tengo que hacer un algoritmo que muestre lo que tarde en ejecutarse el programa, indicando fecha y hora de inicio e termino. Lo hice pero me tira error en la fila 19, si alguien me puede ayudar con ese problema o cambiar el algoritmo para saber fecha y hora se lo agradecería un montón, saludos! Aquí va el código:
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
62
63
64
65
66
#include <stdio.h>
#include <ctime>
#include <sys/timeb.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;
int numeros[1000];
void pensarnumeros(void);
void ordenarnumeros(void);
int N,i,j;
int main(void)
{
	struct timeval ti, tf;
	double tiempo;
	gettimeofday(&ti, NULL);   // Instante inicial
	cout<<"\n\n ¨Cuantos n£meros desea crear aleatoriamente?(max 1000)N=";
	scanf("%d",&N);
	pensarnumeros();
	ordenarnumeros();
	getch();
}
void pensarnumeros(void)
{
	int conta=0;
	srand((unsigned)time(NULL));
	cout<<"\nCreados:\n";
	for(i=0;i<N;i++)
	{
		conta++;
		numeros[i]=rand()/327;
		printf(" %d ",numeros[i]);
		if(conta % 15==0)
		{
			cout<<"\n";
		}
 
	}
}
void ordenarnumeros(void)
{
	int j,k,t,conta=0;
	for(j=1;j<N;j++)
 		for(k=0;k<N-1;k++)
 		{
  			if(numeros[k+1]<numeros[k])
  			{
  				t=numeros[k];
  				numeros[k]=numeros[k+1];
  				numeros[k+1]=t;
  			}
 		}
 	cout<<"\nOrdenados:\n";
	for(i=0;i<N;i++)
	{
		conta++;
		printf(" %d ",numeros[i]);
		if(conta % 15 == 0)cout<<"\n";
	}
	gettimeofday(&tf, NALL);   // Instante final
    tiempo= (tf.tv_sec - ti.tv_sec)*1000 + (tf.tv_usec - ti.tv_usec)/1000.0;
    printf("Demora en ejecutarce: %g milisegundos\n", tiempo);
    system("PAUSE");
    return EXIT_SUCCESS:
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 661
Bronce
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

Ayuda con algoritmo

Publicado por agustin (522 intervenciones) el 17/11/2015 07:41:55
Y cual es la línea 19? Y que error te da exactamente?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar