Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "VenturaLibrary.h"
- int disboy(char instruccionPal[20],int tiempoPal){
- int j = strlen(instruccionPal)-1;
- if(tiempoPal > 5){
- for(int i=0; i<strlen(instruccionPal)/2;i++,j--)
- {
- if(*(instruccionPal+i)!= *(instruccionPal+j)){
- return 0;
- }else{
- return 1;
- }
- }
- }
- else{
- return 0;
- }
- }
- Ins* anadirInstruccion(Ins *head , char instruccion[20], int tiempo) //Ins *rootFromMain
- {
- if(head == NULL) //si no existe la lista, esto es, no hay memoria asignada, se crea el primer elemento 1 sola vez
- {
- head = (Ins *)malloc(sizeof(Ins));
- if(head == NULL) //opcional pero una buena práctica es preguntar si fue posible porque sí hubo memoria disponible
- {
- return NULL; // será la convención (en esta clase) de que no hubo éxito
- }
- strcpy(head->command,instruccion);
- head->tiempo = tiempo;
- head->Next = NULL;
- return head; // 1 será la convención (en esta clase) de que sí hubo éxito
- }
- else //si ya existe el head se estarán agregando (este código es el que se estará ejecutando la mayoría de las veces
- {
- Ins *temporal = (Ins *)malloc(sizeof(Ins));
- Ins *current = head;
- if(temporal == NULL) //opcional pero una buena práctica es preguntar si fue posible porque sí hubo memoria disponible
- {
- return NULL; // será la convención (en esta clase) de que no hubo éxito
- }
- strcpy(temporal->command,instruccion);
- temporal->tiempo = tiempo;
- temporal->Next = NULL;
- while(current->Next != NULL) //esto es para ir "caminando" y añadir al final el elemento
- {
- current=current->Next;
- }
- current->Next = temporal;
- return head;
- }
- }
- void recorrer (Ins* head)
- {
- Ins *temp = head;
- printf("Recorriendo...\n");
- while(temp) {
- printf("Nombre: %s\n", temp->command);
- printf("Tiempo: %d\n", temp->tiempo);
- temp = temp->Next ;
- }
- }
- Ins* mandarInstrucciones(Ins *head) //en otras palabras, borrar
- {
- Ins *temp = head;
- printf("Recorriendo...\n");
- while(temp) {
- printf("Borrando{ Nombre: %s\n }\n", temp->command);
- head = temp->Next;
- free(temp);
- temp = head;
- }
- return NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement