NODO < Filler > * BST < Filler > :: Successore ( NODO < Filler > * Nodo, Filler Key ){ NODO < Filler > * Y; Y = NULL; while ( Nodo && Nodo->GetElem() != Key ){ if ( Nodo->GetElem() < Key ){ Nodo = Nodo->GetRight (); } else{ Y = Nodo; Nodo = Nodo->GetLeft(); } } if ( Nodo && Nodo->GetRight () ){ Y->SetElem ( Minimo( Nodo->GetRight() ) ); } return Y; }
//LEER ARCHIVOS ASCII y almacenarlos en un vector. void LeerASCII(FILE *entrada, char formato, int tareas) { //Variables. int i; i = 0; if(formato == 'd') //Leer enteros. { int valor; valor = 0; while(fscanf(entrada, "%d", &valor) == 1) { i++; } //Se crea el vector que contendra los valores. int *vector; vector = (int *) malloc(i * sizeof(int)); fseek(entrada, 0, SEEK_SET); //Volvemos al inicio del archivo. i = 0; fprintf(stdout, "Los valores leidos son:\n"); //Reescanear y almacenar valores. while(fscanf(entrada, "%d", &vector[i]) == 1) { fprintf(stdout, "%d\n", vector[i]); i++; } //Se invoca a las funciones que realizan los calculos. Minimo(tareas, i, vector); } else //Leer flotantes. { float valor; valor = 0; while(fscanf(entrada, "%f", &valor) == 1) { i++; } //Se crea el vector que contendra los valores. float *vector; vector = (float *) malloc(i * sizeof(float)); fseek(entrada, 0, SEEK_SET); //Volvemos al inicio del archivo. i = 0; fprintf(stdout, "Los valores leidos son:\n"); //Reescanear y almacenar valores. while(fscanf(entrada, "%f", &vector[i]) == 1) { fprintf(stdout, "%f\n", vector[i]); i++; } } }