#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
void drawMan(int life);
void game(void);
char *voca[] = {"accolade","adamant","admonition","affable","affinity","aftermath","ailing","aisles","amenable","amidst","among","apocryphal","appall","arousal","assuage","awash","bared","barely","bear","beef","beg","bend","bend","beneath","bequest","besiege","bet","bind","binge","blade","blasphemy","blast","blazing","blister","blow","blunt","boast","bobbing","bolster","bout","brag","brash","breed","brevity","bribe","brusque","burden","burglary","burst","cacophony","calf","callus","captivity","cartons","catering","cattle","cease","censure","chimera","chuckle","churning","claim","clam","clamor","clash","clemency","clever","clumsy","clutch","coalesce","cock","coeds","cognizant","come about","commiserate","complaisant","comprised","concealed","concern","contract","convey","convict","copious","copper","couch","crap","craze","crop","crotch","culprit","cumbersome","curl","dainty","dairy","dare","dart","dawn","dazzling","deaf","dean","dearth","decadence","decay","deceive","deed","defy","demise","denim","dentures","depleted","deputy","desultory","deter","devise","diatribe","dimple","dire","disgruntled","dispassionate","distress","donor","downwind","doze","draped","dreary","drizzling","drowziness","dull","dumb","duplicity","duty","dye","ease","edge","edifice","eerie","effervescent","eloquent","embrace","endowed","endure","enmity","equivocal","erroneous","exemplary","expedient","exuberance","fad","faint","fair","fancy","fast","feat","feather","fetter","fidget","fizz","flair","flare","flaw","fledgling","flood","flunk","folly","footstool","frantic","fright","fringe","frivolous","fulfill","garbled","garments","garner","gauntlet","gerbil","giggle","glazed","gloomy","gorgeous","grated","gravel","gravity","greedy","grief","grim","grip","groan","groovy","groping","ground","grudge","gut","hackneyed","haggle","hail","haphazard","harm","harsh","harvest","hassle","hasty","hatch","haunt","haze","heal","hedge","heel","heist","hen","herd","heretic","hermit","hindrance","hindsight","hobbling","hold dear","hollow","hue","hurtle","impart","incessant","incidental","incite","indefatigable","indelible","infraction","inmate","insolvent","intricate","irascible","irresolute","jargon","jeopardy","jiggle","keen","kindle","knack","knob","ladder","lagging","lame","lampoon","languish","lavish","lead","lean","lease","leather","leery","leniency","levity","likely","limb","limp","loaf","loony","loosely","loquacious","lousy","ludicrous","lump","lurches","maize","meander","mend","mere","messy","miff","mild","misanthrope","mischievous","misleading","mock","mold","mole","mood","morose","moss","muck","mug","mull","nave","neat","negligent","nonchalance","obey","obtuse","odorless","offspring","onset","opaque","opulence","orchard","outnumber","outward","overwhelming","parsimonious","partake","paucity","paw","peak","peel","peripheral","peruse","pinch","plea","pledge","poised","popsicle","porch","poultry","pouring","praise","prank","preach","prodigal","profane","progeny","progeny","proximity","prudish","puddle","puffy","pulled","pun","pursuit","put up with","quarrel","querulous","rage","rash","rave","rebuke","recapitulate","recluse","regret","rehearse","rekindle","relieve","rely","remain","renounce","repent","reproach","rescind","resemble","respite","retreat","ribbing","riddle","ridge","rinds","ripe","roaring","roll out","rot","rough","rouse","rug","ruminate","ruse","rust","sagacious","sage","sate","savants","scrawl","screech","screw","scrutinize","seal","seam","seizing","sentient","settle","sew","shackle","shed","shelter","shingles","shiv","shoplift","shore","shriking","shrink","silk","silly","skewer","slash","slaughter","slight","slippers","slope","slug","slum","slump","sly","smear","snail","snap","snore","snub","soaked","sober","somber","soothed","sovereignty","sparkle","spotter","spouting","spree","spurious","squalid","squeeze","squirm","stage","stagnant","stale","stare","stark","steady","steep","stem cell","stickler","sticky","stiff","stingy","stir","stoic","stony","stooped","strain","stretch","stride","stripes","stroll","struck","stubborn","stun","stunt","substantiate","sulky","supplant","surreptitious","swallow","swamp","swath","sway","sweepings","thick","thigh","thorn","thrifty","tickle","tide","torpor","touchy","trite","trousers","trustee","trustworthy","tuckered","turd","udder","unassailable","uncanny","undergo","underneath","uniform","unobstrusive","unpleasant","unscathed","untenable","upbeat","upsetting","vacillate","vanish","veal","vex","vilify","vogue","voluminous","voracious","waist","wart","wax","weave","wedge","weeds","weird","welfare","whalebone","whinning","whipping","wholly","widen","wilted","wipe","wisdom","wise","wool","wool","worthy","wreck","wriggle","writhe"};
// 506 words
int main(void){
srand(time(NULL));
game();
return 0;
}
void game(void){
// Insert source code for Hangman game...
char *a=voca[rand()%506], alph[100],answer[100]="";
int len = 0,i = 0,j=0,m=0, n=0, life=7,e=1;
len = (strlen(a));
// scanf("%s",alph);printf("%c",alph[0]);
printf("Guess the word: ");
for(i=0 ;i < len ; i++)
printf("_ ");//¸Ç óÀ½ ½ÃÀÛ. ¸ðÁ¶¸® ºóÄ
printf("\n");
printf("%s,%d,%c",a,len, a[0]);
while(life>0 || life==0){
scanf("%s ",alph);
if(life>0){
if(strlen(alph)==1){
if((alph[0]>('A'-1)) || (alph[0]<('Z'+1)))
alph[0]=(alph[0]-'A'+'a');
else if((alph[0]>('a'-1)) || (alph[0]<('z'+1)))
alph[0]=alph[0];
printf("Guess the word: ");
for(j=0;j<len;j++){
if( a[j]!=alph[0]){
answer[j]='_';
e++;
}
else if(a[j]==alph[0])
answer[j]=alph[0];
if(e==len) {
life--;
drawMan(life);
}
}
printf("%s",answer);
}
else if( strlen(alph)==len){
for(m=0;m<len;m++){
if((alph[m]>('A'-1)) || (alph[m]<('Z'+1)))
alph[m]=(alph[m]-'A'+'a'+1);
else if((alph[m]>('a'-1)) || (alph[m]<('z'+1)))
alph[m]=alph[m];
}//ÇѱÛÀÚÀÌ»óÀÇ ¹è¿À» ´Ù ¼Ò¹®ÀÚ·Î ¹Ù²Ù±â
if(alph==a){
printf("Congratulations! You guesses my word! ");
break;
}
else{
life--;
drawMan(life);
}
}
else{
life--;//alph ±æÀÌ°¡ 1°³ ¾Æ´Ï°Å³ª Á¤´äÀ̶û ´Ù¸£¸é ¾µ¸ð°¡ ¾øÁö
drawMan(life);
}
}
else if(life==0){
printf("Game over! The word was %s",a);//life°¡ 0ÀÌ µÇ¸é ³¡³ª´Â°ÅÁö
break;
}
}
}//¹Ýȯ°ªÀÌ ¾øÁö
void drawMan(int life){
switch(life){
case 0:
printf(" O\n/|\\\n |\n/\\\n");
break;
case 1:
printf(" O\n/|\\\n |\n/\n");
break;
case 2:
printf(" O\n/|\\\n |\n");
break;
case 3:
printf(" O\n/|\\\n");
break;
case 4:
printf(" O\n/|\n");
break;
case 5:
printf(" O\n |\n");
break;
case 6:
printf(" O\n");
break;
case 7:
printf("\n");
break;
}
}
1.alph¸¦ ÇѱÛÀÚ·Î ÀԷ¹޴°æ¿ì¿¡´Â ´ë¹®ÀÚ·Î ÀԷ½ÿ¡¸¸ ÇÁ·Î±×·¥ÀÌ µ¹¾Æ°¡´Âµ¥ ¼Ò¹®ÀÚ´Â ¿Ö ¾Èµé¾î°¡´Â °É±î¿ä?
2. alph°¡ Á¤´ä a¿Í °°À¸¸é congratulationÀÌ ³ª¿Í¾ß Çϴµ¥ ¿Ö Ʋ¸°°É·Î ÀνÄÇÒ±î¿ä?¤Ð
3. alph¸¦ ÀԷ¹ÞÀ¸¸é _ ´ë½Å¿¡ ±× ¹®ÀÚ°¡ µé¾î°¡¾ß Çϴµ¥, µé¾î°¡±ä µé¾î°¡´Âµ¥ ±× ´ÙÀ½¹ø alph¸¦ »õ·Î ¹ÞÀ»¶§¿¡ ±× Àü ¹®ÀÚµµ °°ÀÌ ÀÔ·ÂµÈ »óŸ¦ ¾î¶»°Ô À¯ÁöÇϳª¿ä? |