¡Esta es una revisión vieja del documento!
#include <stdio.h> #include <string.h> #include <math.h> #include <time.h> void printTitle(char a[]); void stringToCaps(char a[]); int main(){ int userHand, computerHand; char userHandString[10], computerHandString[10]; int result; int keepAsking; char keepPlaying = 'Y'; /*Start randomizer*/ srand(time(NULL)); while(keepPlaying == 'Y' || keepPlaying == 'y'){ /*Genera mano computada*/ computerHand = rand() % 3; switch(computerHand){ case 0: strcpy(computerHandString, "PIEDRA"); break; case 1: strcpy(computerHandString, "PAPEL"); break; case 2: strcpy(computerHandString, "TIJERA"); break; default: break; } /*Game*/ printTitle("PIEDRA, PAPEL, O TIJERA, por ~peron"); do{ printf("\Piedra, papel o tijera?: "); scanf("%s", userHandString); stringToCaps(userHandString); keepAsking = 0; if(strcmp(userHandString, "PIEDRA") == 0) userHand = 0; else if(strcmp(userHandString, "PAPEL") == 0) userHand = 1; else if(strcmp(userHandString, "TIJERA") == 0) userHand = 2; else keepAsking = 1; }while(keepAsking == 1); printf("\n\nSu mano: %s", userHandString); printf("\nMano del mainframe: %s\n\n", computerHandString); result = userHand - computerHand; if(result < 0) result += 3; switch(result){ case 0: printf("Empatamos, gg\n\n"); break; case 1: printf("USTED GANA!\n\n"); break; case 2: printf("Uy. Usted pierde. FLOR DE NOOB!\n\n"); break; default: break; } do{ printf("Quiere seguir jugando? [Y/N]: "); fflush(stdin); scanf("%c",&keepPlaying); }while(keepPlaying != 'y' && keepPlaying != 'Y'&& keepPlaying != 'n' && keepPlaying != 'N'); system("@cls||clear"); } printTitle("Gracias por jugar en texto-plano!! UwU"); clock_t start_time = clock(); while (clock() < start_time + 1600); return 0; } void printTitle(char a[]){ int j = 0; printf("%c%c",176,177); for(int i = 0; i <= strlen(a)+7; i++) printf("%c",178); printf("%c%c\n",177,176); printf("%c%c%c%c%c ",176,177,178,177,176); while(a[j]!='\0'){ printf("%c",a[j]); j++; } printf(" %c%c%c%c%c\n",176,177,178,177,176); printf("%c%c",176,177); for(int i = 0; i <= strlen(a)+7; i++) printf("%c",178); printf("%c%c\n",177,176); } void stringToCaps(char a[]){ for(int i = 0; i < strlen(a); i++) if(a[i] > 96 && a[i] < 123) a[i] -= 32; }
