행맨인데 banana하고 tongue 여섯글자인게 실행시키면 끝이 안남 도와주면 한국계좌로 돈 쏴준다
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#include <time.h>
// dictionary of words to play with
char *list[] ={
"banana", "programmer",
"tongue", "favourite",
"serendipity", "sportman",
"harmony", "goalkeeper",
"operation", "hamstring",
"vibration", "wonderful"
};
main()
{
int wordi, icount=0, lives=8, i, j;
char *word, letter, *fine, game[20], *tru, getit[0];
srand((unsigned int)time(NULL));
while (icount>=0){
// this block select a random word to start a game
wordi = rand() % 12;
printf("\\n rand index is %d \\n ", wordi);
word = list[wordi];
printf("\\n %s \\n",word);
printf("\\n Let\'s start. You have %d lives \\n ", lives=8);
do{
printf("\\n Next letter: ");
scanf("%s",&letter);
fine=strchr(word,letter);
for(i=0; i<strlen(word); i++){
if (letter==word[i]){
game[i]=letter;
tru[i]=letter;
}
else if(game[i]==word[i]){
game[i]=word[i];
tru[i]=word[i];
}
else
game[i]=\'_\' ;
}
if (strcmp(tru,word)==0){
printf(" The word is %s, you have won !! \\n",word);
break;
}
else if(fine==NULL){
lives--;
printf(" Lives: %d, Current word: ", lives);
for(i=0; i<STRLEN(WORD); i++){
}
if(lives==0){
printf("\\n Game Over \\n");
break;
}
}
else if (fine!=NULL){
printf(" Lives: %d, Current word: ", lives);
for(i=0; i<STRLEN(WORD); i++){
}
}
}while(lives>-1);
fflush(stdin);
while (1)
{
printf("\\n Do you want to play again [Y/N] \\n");
scanf("%s",&getit[0]);
if ((getit[0] == \'N\') || (getit[0] == \'n\'))
return 0;
if ((getit[0] == \'Y\') || (getit[0] == \'y\'))
break;
}
icount++;
}
}
실행했을때 아래와 같이 나와야함
Let\'s start. You have 8 lives
Next letter: a
Lives: 8, Current word: ______a_
Next letter: n
Lives: 8, Current word: ______an
Next letter: s
Lives: 8, Current word: s_____an
Next letter: t
Lives: 8, Current word: s___t_an
Next letter: o
Lives: 8, Current word: s_o_t_an
Next letter: r
Lives: 8, Current word: s_ort_an
Next letter: p
Lives: 8, Current word: sport_an
Next letter: m
The word is sportman, you have won !!
Do you want to play again [Y/N]
Y
Let\'s start. You have 8 lives
Next letter: a
Lives: 8, Current word: ____a____
Next letter: o
Lives: 8, Current word: ____a__o_
Next letter: r
Lives: 8, Current word: ___ra__o_
Next letter: s
Lives: 7, Current word: ___ra__o_
Next letter: t
Lives: 7, Current word: ___rat_o_
Next letter: m
Lives: 6, Current word: ___rat_o_
Next letter: n
Lives: 6, Current word: ___rat_on
Next letter: i
Lives: 6, Current word: _i_ration
Next letter: m
Lives: 5, Current word: _i_ration
Next letter: d
Lives: 4, Current word: _i_ration
Next letter: c
Lives: 3, Current word: _i_ration
Next letter: g
Lives: 2, Current word: _i_ration
Next letter: g
Lives: 1, Current word: _i_ration
Next letter: b
Lives: 1, Current word: _ibration
Next letter: l
Game Over
Do you want to play again [Y/N]
N
댓글 영역
획득법
① NFT 발행
작성한 게시물을 NFT로 발행하면 일주일 동안 사용할 수 있습니다. (최초 1회)
② NFT 구매
다른 이용자의 NFT를 구매하면 한 달 동안 사용할 수 있습니다. (구매 시마다 갱신)
사용법
디시콘에서지갑연결시 바로 사용 가능합니다.