|
||
| Array ile basit ve anlaşılır bi adam asmaca oyunu #include<iostream> #include<cstdlib> using namespace std; int main(){ char word[30]="sandalye"; char name[30]; char x; int counter; cout<<"welcome to hangman\n"; cout<<"lets guess the word\n"; for(int i=0;word!='\0';i++){ name='*'; } cout<<name; for(int j=0;j<=9;j++){ cout<<"\n"; cout<<"enter a guess\n"; cin>>x; x=tolower(x); for(int i=0;word!='\0';i++){ if(word==x) name=word; } cout<<name; int counter=0; for(int k=0;word[k]!='\0';k++){ if(name[k]!=word[k]) counter++;} if(counter==0){ cout<<"\n"; cout<<"congratulations you win"; j=11;} } cout<<"\n"; cout<<"BYE BYE"; cout<<"\n"; system("pause"); return 0; } |
||