void procesaLista( LISTA *lA ) { int orden, opc, numAux; do { opc = imprimeMenu(); switch( opc ) { case 1: numAux = leerNum(); insertaNodo( lA, numAux ); // printf( "\n Nodos de A: %d ", *nEa ); system( "pause" ); break; case 2: imprimeLista( *lA ); system( "pause" ); break; case 3: orden = determinaOrdenRec( *lA ); if( orden == 1 ) printf( "\n Las lista esta ordenada crecientemente " ); else printf( "\n Las lista no esta ordenada ascedentemente " ); system( "pause" ); break; case 4: numAux = leerNum(); if( busquedaRecursiva( *lA, numAux ) ) printf( "\n El elemento se ha encontrado " ); else printf( "\n El dato no esta en la lista " ); system( "pause" ); break; default: completaLista( *lA ); } }while( opc > 0 && opc < 6 ); }
/** Read tarball header and store it in memory. * * tarFile: pointer to the tarball's FILE descriptor * header: output parameter. It is used to return the starting memory address * of an array that contains the (name,size) pairs read from the tar file * nFiles: output parameter. Used to return the number of files stored in * the tarball archive (first 4 bytes of the header) * * On success it returns EXIT_SUCCESS. Upon failure, EXIT_FAILURE is returned. * (both macros are defined in stdlib.h). */ int readHeader(FILE * tarFile, stHeaderEntry ** header, int *nFiles) { int i, n=0; char c; stHeaderEntry* p; *nFiles = leerNum(tarFile); //Leo el numero de archivos del mtar if((p = (stHeaderEntry*)malloc((*nFiles)*sizeof(stHeaderEntry)))==NULL) return EXIT_FAILURE; for(i = 0; i<*nFiles; i++){ //Leo el nombre de las cadenas y su tamaño y lo guardo en la estructura de la cabecera con todos los datos if(loadstr(tarFile, &p[i].name)==EXIT_FAILURE) //de los archivos que contiene el tar return EXIT_FAILURE; p[i].size = leerNum(tarFile); } *header = p; //El valor de header será el de p return EXIT_SUCCESS; }
int capturaLista( LISTA *lA, LISTA *lB, int *nEa, int *nEb ) { int resIgual, opc, numAux; do { opc = imprimeMenu(); switch( opc ) { case 1: numAux = leerNum(); insertaNodo( lA, numAux, nEa ); printf( "\n Nodos de A: %d ", *nEa ); system( "pause" ); break; case 2: numAux = leerNum(); insertaNodo( lB, numAux, nEb ); printf( "\n Nodos de B: %d ", *nEb ); system( "pause" ); break; case 3: resIgual = determinaIgualdad( *lA, *lB, *nEa, *nEb ); if( resIgual == 1 ) printf( "\n Las lista son iguales " ); else printf( "\n Las lista son diferentes " ); system( "pause" ); break; case 4: imprimeLista( *lA, *lB ); break; } }while( opc > 0 && opc < 5 ); return( resIgual ); }
void recorridoDeCaballo( int t[][T_V], int h[T_H], int v[T_V], int tam ) { int filaA, columnaA, contador, i ,numMov, bandera = 1 ; filaA = columnaA = contador = 0; t[filaA][columnaA] = 0; srand ( time(NULL) ); while( contador < 64 && bandera ) { do { numMov = leerNum(); filaA += v[numMov]; columnaA += h[numMov]; if ( ( ( filaA >= 0 ) && (filaA < tam ) )&& ( ( columnaA >= 0 ) && (columnaA < tam ) ) ) if ( t[filaA][columnaA] == 0 ) t[filaA][columnaA] = contador; else { for ( i = 0; i<tam; i++) { filaA = columnaA = 0; filaA += v[numMov]; columnaA += h[numMov]; if ( t[filaA][columnaA] == 0 ){ t[filaA][columnaA] = contador; break; } } } if ( i == tam ) bandera = 0 ; }while( ( ( filaA < 0 ) && (filaA > tam ) )&& ( ( columnaA < 0 ) && (columnaA > tam ) ) ); contador++; } }