示例#1
0
int main()
{
    
    // capacidad de los punteros a enteros
    int tam[] = {1000, 2000, 4000, 8000, 16000, 32000};
    float *t_inv = (float*) malloc (6*sizeof(float));
    float *t_ale = (float*) malloc (6*sizeof(float));;
    
    obtencionDatos(tam, 6, t_inv, t_ale);
    
    printf("      Tiempo del vector en orden inverso   Tiempo del vector en orden aleatorio\n\n");
    int i;
    for(i = 0;i<6;i++)
    {
        if (tam[i]<10000)
            printf(" ");
        printf("%d%35.5f%39.5f\n",tam[i],t_inv[i],t_ale[i]);
    }
    
    free (t_inv);
    free (t_ale);
    
    return 0;
    
}
int main(int argc, char **argv){
	bool debug = false;
	int tam [] = { 1, 2, 4, 8, 16, 32};
	int n = 6;
	float timeDesc [n];
	float timeRandom [n];
	int multiplier = 1000;
	printf("\nBad Sorting, a (very) bad way to order arrays. \n\n" );
	printf("Use $./badOrdering debug to use a minor set. \n" );
	for (int i = 0; i < argc; ++i){

        if( strcmp("debug", argv[i]) == 0){
        	debug = true;
        }
    }

	if(!debug){
		printf("Preparing the basic array, a set 1000-32000 will be used...\n\n");
		for (int i = 0; i < n; ++i){
			tam[i] = tam[i]*multiplier;
		}
	}else{
		printf("Debug is on, a set 1-32 will be used.\n");

	}
	obtencionDatos( tam, n, timeDesc , timeRandom);
	printDatos( tam, n, timeDesc , timeRandom);

	return 0;
}