Hang man game in c++

Code

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include <stdlib.h>
using namespace std;

int main()
{

int a;   
cout<<"              ------------------------------------------------"<<endl;   
cout<<"                        Welcome To the HAng MaN Game "<<endl;   
cout<<"              ------------------------------------------------"<<endl<<endl;
cout<<"                         |(((( Player OnE )))) | "<<endl<<endl ;
cout<<" HOW many character U Want to ENter == ";
cin>>a;
int g=11;   

char ch[a],new1[a],word[a];
cout<<" \n \n";
cout<<"\n \n PLZ Insert Yr COmplete Words ==== ";

for(int b=0;b<a;b++)
  { new1[b]='_';
     
    cin>>ch[b];
  }   
f:
system("cls");

cout<<"                         ------------------------- \n ";
cout<<"                              PLayer Two  \n";   
cout<<"                         ------------------------- \n\n ";
cout<<"                      ****************************** \n";   
cout<<"                             GUess The characters  \n ";   
cout<<"                      ****************************** \n \n \n";   

                                                                       
cout<<"YOu have "<<g<<" tries Other wise your man will Hang \n\n";

cout<<"your Enter Charater Are === ";
for(int t=0;t<a;t++)
{
cout <<new1[t];   
}
cout<<"\n";
if(g==10)
{
cout<<"                                                     /       "<<endl;
}
if(g==9)
{
cout<<"                                                     /       "<<endl;           
cout<<"                                                    /        "<<endl;
}
if(g==8)
{
cout<<"                                                    __       "<<endl;           
cout<<"                                              *-*-* /        "<<endl;         
cout<<"                                                   /         "<<endl; 
}
if(g==7)
{
   
cout<<"                                                    __        "<<endl;         
cout<<"                                              *-*-* /         "<<endl;  
cout<<"                                              ('_')/          "<<endl; 
}
if(g==6)
{
cout<<"                                                    __        "<<endl;           
cout<<"                                              *-*-* /         "<<endl;         
cout<<"                                              ('_')/          "<<endl;  
cout<<"                                                |             "<<endl;   
}
if(g==5)
{

cout<<"                                                    __        "<<endl;           
cout<<"                                              *-*-* /         "<<endl;         
cout<<"                                              ('_')/          "<<endl;  
cout<<"                                                |             "<<endl;
cout<<"                                                |             "<<endl;   
}

if(g==4)
{
cout<<"                                                    __        "<<endl;           
cout<<"                                              *-*-* /         "<<endl;         
cout<<"                                              ('_')/          "<<endl;  
cout<<"                                                |             "<<endl;
cout<<"                                               /|             "<<endl; 
 
   
}
if(g==3)
{
cout<<"                                                    __        "<<endl;           
cout<<"                                              *-*-* /         "<<endl;         
cout<<"                                              ('_')/          "<<endl;  
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl;     
}


if(g==2)
{
cout<<"                                                    __        "<<endl;           
cout<<"                                              *-*-* /         "<<endl;         
cout<<"                                              ('_')/          "<<endl;  
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl; 
cout<<"                                                |             "<<endl;
}
if(g==1)
{
cout<<"                                                    __        "<<endl;           
cout<<"                                              *-*-* /         "<<endl;         
cout<<"                                              ('_')/          "<<endl;  
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl; 
cout<<"                                                |             "<<endl;
cout<<"                                               / \\           "<<endl;

}
cout<<"\n\n";
cout<<" Enter charater ====" ;

int c,m=-1,l=0;
 for(int b=1;b<=a+a;b++)
 {                                   
    cin>>word[b];
    for( c=0;c<a;c++)
      {
        if(word[b]==ch[c])
        {
            
        new1[c]=word[b];
       
         m=c;
        }
       
       }
 if(m==-1)
g--;     
 break;     
 }


 for(int p=0;p<a;p++)
if(ch[p]==new1[p])
{
l++;   
}
else
{ if(g>0)
 goto f;
system("cls");
cout<<"\n\n";
cout<<"                             -------------------         \n ";
cout<<"                             (((  You LOst ))))           \n ";
cout<<"                            -------------------         \n\n\n ";
cout<<"                                          __        "<<endl;           
cout<<"                                    *-*-* /         "<<endl;         
cout<<"                                    ('_')/          "<<endl;  
cout<<"                                      |             "<<endl;
cout<<"                                     /|\\           "<<endl; 
cout<<"                                      |             "<<endl;
cout<<"                                     / \\           "<<endl;

cout<<"Right Answer is ====== ";
for(int t=0;t<a;t++)
{
cout <<ch[t];   
}
cout<<"\n\n\n\n\n";    
}

if(l==a)
{
system("cls");

for(int t=0;t<a;t++)
{
cout <<new1[t];   
}
cout<<"\n\n\n\n\n\n";
cout<<"                             -------------------         \n ";
cout<<"                              (((  You Won ))))           \n ";
cout<<"                            -------------------         \n\n\n\n\n ";
   
}
 getche();
}

 <<<<<<<<<<<<<<<, ----------------------------------- >>>>>>>>>>>>>>>>>>>
 

Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

2 comments:

Powered by Blogger.

Translate

 
 
.