Пример #1
0
int main(){

	FILE *fp;
	char cadena[100];
	struct Alumno *inges, *lista, *temp;

	fp=fopen("alumnos.txt", "r");

	lista = creaNodo();

	if(fp==NULL){
		printf("No existe el archivo LOL!!");
		return 0;
	}


	while(!feof(fp)){
		inges = creaNodo();
		fscanf(fp, "%s\n", cadena);
		corta(cadena, inges);
		insertaNodo(lista, inges);
		printf("%s\n",inges->nombre); 
	}

	temp = lista->sig;
	muestraLista(temp);

	fclose(fp);


	return 0;
}
void insertaNodo(LISTA *ptrLista, int dato )
{  
   LISTA ptrNuevo;
   
   if( creaNodo( &ptrNuevo, dato ) )
   {
     ptrNuevo -> liga = *ptrLista;
     *ptrLista = ptrNuevo;
   }
}
Пример #3
0
int creaMalla(Malla *cab, Malla *dino)
{
    Malla cx1, cx2, cy, cxAux;
    int res=1, x, y;

    for(y=0; y<M && res; y++, cxAux=cy)
        for(x=0; x<N && res; x++)
        {
            if( x==3 && y==M-1)
            {
                res=creaNodo(&cx1,0);
                *dino=cx1;
            } else
                res=creaNodo(&cx1,0);

            if(res)
                if(!y)
                    if(!x)
                        *cab=cx2=cy=cx1;
                    else
                    {
                        cx1->izq = cx2;
                        cx2->der = cx1;;
                        cx2=cx1;
                    }
                else
                {
                    if(!x)
                        cx2=cy=cx1;
                    else
                    {
                        cx1->izq = cx2;
                        cx2->der = cx1;
                        cx2 = cx1;
                    }
                    cx1->arriba=cxAux;
                    cxAux->abajo=cx1;
                    cxAux = cxAux->der;
                }
        }

    return(res);
}
void completaLista( LISTA ptrLis )
{
  
  LISTA nuevo;
  
  if( ptrLis )
  {
    do
    {
      if( ptrLis -> liga && ptrLis -> inf + 1 < ptrLis -> liga -> inf )
          if( creaNodo( &nuevo , ptrLis -> inf + 1 ) )
          {
            nuevo -> liga = ptrLis -> liga;
            ptrLis -> liga = nuevo;
          }
      
      ptrLis = ptrLis -> liga;
          
    }while( ptrLis );   
  }
  
}
void insertaNodo( LISTA *ptrLista )
{
  srand( time( NULL ) );
  
  LISTA ptrNuevo = NULL;   
  int opc;
  
  printf( "\n Digite 1 para insertar nodos 0 para terminar " );
  scanf( "%d", &opc );
  
  while( opc )
  {
     if( creaNodo( &ptrNuevo, rand()% + 50   ) )
     {
        ptrNuevo -> liga = *ptrLista;
        *ptrLista = ptrNuevo;
     }
     
     printf( "\n Continuar ?" );
     scanf( "%d", &opc );
  }
}
Пример #6
0
int addPerm(nodo_t ** r, permesso_t * pp)
{
    if (pp == NULL) {
        errno = EINVAL;
        return 1;
    }
    if (*r == NULL) {
        if ((*r = creaNodo(pp)) == NULL)
            return 1;
        else
            return 0;
    } else {
        int discr = strcmp((*r)->targa, pp->targa);
        /**esiste gia un nodo per la targa.
        * mi limito ad aggiornare la lista degli intervalli*/
        if (discr == 0) {
            /**devo controllare che la il nuovo permesso sia stato aggiunto*/
            return addIntervallo(&((*r)->lint), &(pp->in));
        } else if (discr < 0) {
            return addPerm(&((*r)->right), pp);
        } else
            return addPerm(&((*r)->left), pp);
    }
}
Пример #7
0
void creaMalla( MALLA *m)
{
   int i,j, x, y;
   NODO_MALLA aux, antRen,nuevo;
   
   void *imagen;
   y = 100;
   
   //printf( "\n x: %d y :%d " ,nR, nC );
   //printf( "\n  m : %p\n "  , m );
   
   srand( time(NULL ) );
   
 
   for( i = 1; i <= m -> nRen; i++, y += 36  )
   {
        x = 50;
     for( j = 1; j <= m -> nCol; j++ ,x += 90)
     {
       switch(j)
       {
         case 1:  imagen = abrirImagen( "robot" );
                  break;
         case 2:  imagen = abrirImagen( "robotCd" );
                  break;
         case 3:  imagen = abrirImagen( "robotCd2" );
                  break;
       }  
        
        if( creaNodo( &nuevo, imagen , x , y ) )
          { 
               if( i == 1 )
               {
                    if( !m -> pri ){
                         m -> pri = nuevo;  
                         aux = m -> pri;
                    } else
                        {
                           m -> ult -> sig= nuevo;
                           nuevo -> ant = m -> ult;
                        } 
                      
                      m -> ult = nuevo;
                      m -> ult -> sig = m -> pri;
               }else
                   {
                     if( !antRen -> abajo )
                     {
                        antRen -> abajo = nuevo;
                        nuevo -> arriba = antRen;
                        aux = antRen -> abajo;
                     }else
                        {
                           
                           antRen -> abajo -> sig = nuevo;
                           antRen -> sig -> abajo = nuevo;
                           nuevo -> ant = antRen -> abajo;
                           nuevo -> arriba = antRen -> sig;
                           
                           antRen = antRen -> sig;
                                                   
                         }
                  }
              }
            
           }       
           antRen = aux;
     }
}