int comprueba (struct nodoa *r, struct nodoa *r2, int num) { int uno = 1, dos = 1; if (num) { if (r->clave == r2->clave) { if (r->i) uno = comprueba (r->i, r2->i, uno); if (r->d) dos = comprueba (r->d, r2->d, dos); } else uno = 0; if ((uno == 1) && (dos == 1)) return (uno); else return (0); } }
void alreves (struct nodoa *r, char *cad) { int dato, uno = 1; struct nodoa *r2; FILE *archi; struct nodoa *aux; r2 = NULL; archi = fopen (cad, "rb"); fread (&dato, sizeof (int), 1, archi); while (!feof (archi)) { printf ("%d ", dato); alta (&r2, dato); fread (&dato, sizeof (int), 1, archi); } uno = comprueba (r, r2, uno); if (uno) printf ("Los árboles son idénticos.\n"); else printf ("La hemos cagao.\n"); fclose (archi); }
int main (int argc, char *argv[]) //MAIN FUCNTION { //matriz del juego //Game "Board" with the dots char av[25][80]= { "*******************************************************************************", "*.............................................................................*", "*...***********.............***********..................***** *****..........*", "*...***********.............***********..................*...*.*...*..........*", "*...**......................***********..................*.........*..........*", "*...**.********.............***********..................*...*.*...*..........*", "*...**......................***********..................***** *****..........*", "*...***********...............................................................*", "*...***********...............*********............*********..................*", "*............**...............*********............*********..................*", "*...***********...............*********............*********..................*", "*...***********...............................................................*", "*..............................*************************************..........*", "*..............................*************************************..........*", "*....***********...............*************************************..........*", "*....***********..............................................................*", "*....***********...................................................******.....*", "*........................*******************.......................******.....*", "*.....****...............*******************.*********************.******.....*", "*.....******.............***.............***.......................******.....*", "*.....*********..........***....*****....***.......................******.....*", "*.....*********..........***....*****....***.......................******.....*", "*.............................................................................*", "*******************************************************************************", }; //matriz del juego //Game "Board" with the dots char av2[25][80]= { "*******************************************************************************", "* *", "* *********** *********** ***** ***** *", "* *********** *********** * * * * *", "* ** *********** * * *", "* ** ******** *********** * * * * *", "* ** *********** ***** ***** *", "* *********** *", "* *********** ********* ********* *", "* ** ********* ********* *", "* *********** ********* ********* *", "* *********** *", "* ************************************* *", "* ************************************* *", "* *********** ************************************* *", "* *********** *", "* *********** ****** *", "* ******************* ****** *", "* **** ******************* ********************* ****** *", "* ****** *** *** ****** *", "* ********* *** ***** *** ****** *", "* ********* *** ***** *** ****** *", "* *", "*******************************************************************************", }; char ce=16; int num=1; int op; int num2=1; HANDLE hOut;//Color hOut = GetStdHandle(STD_OUTPUT_HANDLE);//Color SetConsoleTextAttribute(hOut, BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY);//Color Menu(); //Menu function switch(opc){ case 1: clock_t d; d=clock(); av[1][1]=ce; if (hs<1175) { muestra(av, d); while(stop==false) { if (getch() == 224) { op = getch(); } else { op = -1; } switch (op) {//verifica que tecla se preciono y realiza el movimiento //Check which key was pressed and moves case ARR: if (comprueba(av, av2, num, num2-1)==true) {//pregunta si el movimiento es posible o no, para no salirse de los muros //Checks if the move is valid, avoiding crossing the walls av[num2][num]=' '; num2--; ce=30; av[num2][num]=ce; } break; case ABJ: if (comprueba(av, av2, num, num2+1)==true) { av[num2][num]=' '; num2++; ce=31; av[num2][num]=ce; } break; case DER: if (comprueba(av, av2, num+1, num2)==true) { av[num2][num]=' '; num++; ce=16; av[num2][num]=ce; } break; case IZQ: if (comprueba(av, av2, num-1, num2)==true){ av[num2][num]=' '; num--; ce=17; av[num2][num]=ce; } break; } muestra(av,d); } } if (hs==1175) { system("CLS"); Highscores(); } return 0; break; case 2: clock_t a; a=clock(); av2[1][1]=ce; if (hs<1175) { timemuestra(av2, a); while(stop==false) { if (getch() == 224) { op = getch(); } else { op = -1; } switch (op) {//verifica que tecla se preciono y realiza el movimiento case ARR: if (comprueba(av, av2, num, num2-1)==true) {//pregunta si el movimiento es posible o no, para no salirse de los muros av2[num2][num]=' '; num2--; ce=30; av2[num2][num]=ce; } break; case ABJ: if (comprueba(av, av2, num, num2+1)==true) { av2[num2][num]=' '; num2++; ce=31; av2[num2][num]=ce; } break; case DER: if (comprueba(av, av2, num+1, num2)==true) { av2[num2][num]=' '; num++; ce=16; av2[num2][num]=ce; } break; case IZQ: if (comprueba(av, av2, num-1, num2)==true){ av2[num2][num]=' '; num--; ce=17; av2[num2][num]=ce; } break; } timemuestra(av2, a); } } int time; time=timemuestra(av2,a); if (time>=12) { system("CLS"); Highscores(); getchar(); getchar(); } return 0; } }
int main(int argc, char **argv) { int accion = 0; if (argc > 1) accion = argv[1][0] - 48; // Paso del codigo ASCII a decimal if (argc == 5 || (argc == 4 && accion == 2)) { printf("Cifrador Rabbit \n"); // Inicio la clave ctx ECRYPT_ctx * ctx = malloc(sizeof(ECRYPT_ctx)); switch (accion) { case 0: //CIFRAR printf("Seleccionaste Cifrar \n"); printf("El archivo de ORIGEN es: %s \n", argv[2]); printf("El archivo de DESTINO es: %s \n", argv[3]); inicia_ctx(ctx, argv[4]); cifrador_archivo(CIFRAR, argv[2], argv[3], ctx); printf("\n"); printf( " /)_/) \n"); printf( " ( ^.^) Cifrado correcto! \n"); printf( " c(\")(\") \n"); break; case 1: //DECIFRAR printf("Seleccionaste Decifrar \n"); printf("El archivo de ORIGEN es: %s \n", argv[2]); printf("El archivo de DESTINO es: %s \n", argv[3]); inicia_ctx(ctx, argv[4]); cifrador_archivo(DECIFRAR, argv[2], argv[3], ctx); printf("\n"); printf( " /)_/) \n"); printf( " ( ^.^) Decifrado correcto! \n"); printf( " c(\")(\") \n"); break; case 2: //COMPROBAR IMAGENES printf("Seleccionaste Comprobar cifrado \n"); printf("El archivo ORIGINAL es: %s \n", argv[2]); printf("El archivo DECIFRADO es: %s \n", argv[3]); printf("El resultado del proceso es... \n\n"); if (comprueba(argv[2], argv[3]) == 0) { printf( " /)_/) \n"); printf( " ( ^.^) Comprobacion correcta! \n"); printf( " c(\")(\") \n"); } else { printf( " /)_/) \n"); printf( " ( v.v) Comprobacion incorrecta! \n"); printf( " c(\")(\") \n"); } break; default: break; } } return EXIT_SUCCESS; }