Topic Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&itemid=8&page=show_problem& problem=430
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cstdlib>5 using namespacestd;6 7 Const intMAXN = -;8 9 intl, Chance;Ten CharS[MAXN], S2[MAXN]; One intwin, lose; A - voidGuessCharch) - { the intBad =1; - for(inti =0; I < strlen (s); i++) { - if(S[i] = =ch) { -l--; +S[i] ='#'; -Bad =0; + } A } at if(bad)--chance; - if(!chance) Lose =1; - if(!l) win =1; - } - - intMain () in { - intRnd; to #ifndef Online_judge +Freopen ("In.txt","R", stdin); - #endif //Online_judge the while(SCANF ("%d%s%s", &rnd, S, s2) = =3&& rnd! =-1) { *printf"Round%d\n", RND); $Win = lose =0;Panax NotoginsengL =strlen (s); -Chance =7; the for(inti =0; I < strlen (S2); i++) { + guess (s2[i]); A if(Win | | lose) Break; the } + - if(Win) printf ("You win.\n"); $ Else if(lose) printf ("You lose.\n"); $ Elseprintf"You chickened out.\n"); - } - return 0; the}
UVA 489.Hangman Judge Problem Solving report