Coder_Pranav 0 Newbie Poster

This is a famous Indian game called Hollywood-Bollywood.
The rules are............

Create a program for the famous Hollywood bollywood game which will input the number of players and player names initially,

Then it will ask for a movie to be entered by player (x+1) which will be solved by player x.The movie entered by (x+1) will be displayed to x by removing all the consonants and numbers

Example : "abcde12" becomes "a_ _ _ e _ _"

the player will have 9 chances to give the answer which will be inputted character-wise. If the user gives a wrong answer, a chance will be reduced and if it is right, display the character present in the movie. The score of the player will be equal to the number of chances left. after it, (x+1) will solve the movie and (x+1) will enter the movie.

Once a cycle of turn is cpmpleted ask the users to continue and terminate. If continued, repeat in the same manner. If terminated, display the name of the players and their respective scores.

#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
struct player
{
	int pno,score;
	char name[30];
};
player p[30];
int search(char m[50],char c1,int &e)
{
	int i=0,j=0;
	c1=toupper(c1);
	while(m[i]!='\0')
	{
		if(c1==m[i])
		{
			e=i+1;
			j=1;
			break;

		}
		i++;
	}
	c1=tolower(c1);
	i=0;
	while(m[i]!='\0')
	{
		if(c1==m[i])
		{
			e=i+1;
			j=1;
			break;

		}
		i++;
	}
	return j;
}
void main()
{
	clrscr();
	int i,j,n,a,b,d=0,f=0,g=0,col=32;
	char movie[50],c;
	cout<<"ENter the no. of players : ";
	cin>>n;
	for(i=0;i<n;i++)
	{
		cout<<"Enter player no. : ";
		cin>>p[i].pno;
		cout<<"Enter player name : ";
		cin>>p[i].name;
	}
	clrscr();
	j=9;
	char ch='y';
	do
	{       gotoxy(25,2);
		cout<<"HOLLYWOOD BOLLYWOOD!!!!!!!";
		for(i=1;i<=n;i++)
		{
			gotoxy(20,4);
			cout<<"Player " <<i<<"'s turn : ";
			gotoxy(15,6);
			cout<<"Player "<<i+1<<" please enter the movie : ";
			gotoxy(20,9);
			gets(movie);
			a=strlen(movie);
			clrscr();
			gotoxy(25,2);
			cout<<"LET THE GAME BEGIN!!!!!";
			gotoxy(15,6);
			cout<<"The Movie is ";
			for(int k=0;k<a;k++)
			{
				movie[k]=tolower(movie[k]);
				if(isalpha(movie[k]))
				{
					if(movie[k]=='a' || movie[k]=='e' || movie[k]=='o' || movie[k]=='i' || movie[k]=='u')
					{
						cout<<"__"<<" ";
						g++;
					}
				}
				else
				{
					cout<<movie[k]<<" ";
				}
			}
			while(b<j)
			{
				cout<<"Enter your guess : ";
				cin>>c;
				d=0;
				int s=0;
				s=search(movie,c,d);
				if(s==1)
				{
					col=32+(d*3);
					gotoxy(col,6);
					cout<<c;
					f++;

				}
				else
				{
					j--;
				}
				if(f==g)
				{
					cout<<"\n\n\n\tWELL DONE !!!";
					p[i].score=9-b;
					cout<<"\n\n\n\tYour Score : "<<p[i].score;
					break;
				}
				b++;
			}
		}
		cout<<"\n\n\n\n\n\n\n\n\n\nDo you want to play again? (Y/N).";
		cin>>ch;
	}while(ch=='y' || ch=='Y');
	getch();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.