Mesaj: 112
Katılım Tarihi: 2005
|

08.04.2007, 18:41
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
#include <ctype.h>
//#define toupper(int)
//#define tolower(int)
void sec1(void);
void sec2(void);
void guess(void);
int main()
{
int ch;
printf(" WELLCOME TO THE HaNG_MaN v1.0\n");
printf("\n-------------MENU---------------");
printf("\n1.Play with Computer");
printf("\n2.Play with Friend");
printf("\n3.Exit");
printf("\n\nchoice[1-3]..: ");
scanf("%d",&ch);
do
{
switch(ch)
{
case 1: sec1();
break;
case 2: sec2();
break;
case 3: exit(3);
break;
}
}
while(ch>1 && ch<4);
printf("\nWrong choice (;\n\n");
return main();
}
void sec1()
{
char arr[][15]={"cyprus","university","teacher","school","antaly a","turkey","bus","wisconsin","america","sinan" ,
"gargamel","programming","visula","artificial","in teligent","russian","girl","banana","apple","cousi n",
"crystal","istanbul","display","liquid","algorithm ","microsoft","almatı","cherry","fruit","googl e",
"english","einstein","newspaper","gazelle","beauti ful","sony","ericsson","software","dubai","aselsan ",
"nobel","lögitech","samsung","asrock","kingstone", "mause","hangman","glass","camera","cocacola"} ;
char letter,total[15]={'&','&','&','&','&','&','&','&','&','&','&','&', '&','&','&'};
int i,size=0,x,y=0,d=0,t=0,k,index;
//srand(time(NULL));
printf("\n\nCan you guess this word? (;\n");
x=0+rand()%50;
size=strlen(arr[x]);
for(i=0;i<size;i++)
{
printf("_ ");
}
printf("\n");
while(y<(size/2))
{
printf("\nEnter a Letter: ");
fflush(stdin); //tamponda bilgi varsa, bu bilgiyi dosyaya aktarır
scanf("%c",&letter);
for(i=0;i<size;i++)
{
if(letter==arr[x][i])
{
total[i]=letter;
d++;
t++;
}
}
if(d==0)
{
printf("\a");
y++;
}
if(d!=0)
{
for(i=0;i<size;i++)
{
if(total[i]!='&')
{
printf("%c ",total[i]);
}
else
{
printf("_ ");
}
}
}
else
{
printf("%d. times false ",y);
if(y==(size/2))
{
printf("\n\n...GAME OVER...\n\nIf you wanna learn true word press '1'");
scanf("%d",&k);
if (k==1)
{
printf("True answer is '%s'\n\n\n",arr[x]);
return main();
}
}
}
if(t==size)
{
printf("\n\n::.CONGRATULATIONS.::\n\n");
return main();
}
d=0;
printf("\n");
}
}
void sec2()
{
char words[20][50],word[20][50],total[15]={'&','&','&','&','&','&','&','&','&','&','&','&', '&','&','&'};
int e=0,i,size=0,x=0,y=0,d=0,t=0,k,j;
for(j=0;j<2;j++)
{
printf("Enter your words\n");
scanf("%c",&words);
}
printf("\n\n--------------------------------------------------------------\n\n");
//printf("\nWE NEED A SECOND PLAYER NOW..\n\n");
printf("If Second Player Is Ready Please Press 1\n\n");
scanf("%d",e);
if(e==1)
{
srand(time(NULL));
printf("can you guess this word?\n");
// x=0+rand()%50;
size=strlen(words[x]);
for(i=0;i<size;i++)
{
printf("_ ");
}
printf("\n");
while(y<5)
{
printf("\nEnter a Letter: ");
fflush(stdin);
scanf("%c",&word);
for(i=0;i<size;i++)
{
if(word==words)
{
total[i]=word;
d++;
t++;
}
}
if(d==0)
{
printf("\a");
y++;
}
if(d!=0)
{
for(i=0;i<size;i++)
{
if(total[i]!='&')
{
printf("%c ",total[i]);
}
else
{
printf("_ ");
}
}
}
else
{
printf("%d. times false ",y);
if(y==5)
{
printf("\n\n...GAME OVER...\n\nIf you wanna learn true word press '1'\n\n");
scanf("%d",&k);
if (k==1)
printf("True answer is '%s'\n",words[x]);
else
continue;
}
}
if(t==size)
{
printf("\n\n::.CONGRATULATIONS.::\n\n");
continue;
}
d=0;
printf("\n");
}
}
}
|