Home > Back-end >  The purple book chapter iv function and recursive
The purple book chapter iv function and recursive

Time:11-04

Uva489
A good state of the topic and function word problems


#include
#include
Char [100] s1 and s2 [100].
Int win, lose;
Int left to chance;
Void guess (char ch) {
Int bad=1;//the default button blood
for(int i=0; iIf (ch==s1 [I]) {
S1 [I]=' ';//if success full to 0
Bad=0;//don't buckle blood
The left -;//letter little
}
}
If (bad) chance -;//state judgment
if(! Lose chance ()=1;
if(! Left) win=1;
}
Int RND.
Int main ()
{
While (the scanf (" % d ", & amp; RND)! EOF)={
If (RND==1) {
break;
}
Win=0;
Lose=0;
Chance=7;
Printf (" Round % d \ n ", RND);
The scanf (" % s % s ", s1, s2);
Left=strlen (s1);
for(int i=0; i[I] guess (s2);
If (win) break;
If (lose) break;
}
If (win) {
Printf (" You win. \ n ");
}
Else if (lose) {
Printf (" You lose. \ n ");
}
The else printf (" You chickened out. \ n ");
}
return 0;
}
  • Related