i have tried to write a code, but i have a problem with the play() module where the message "one Row Completed" is not being displayed. Please help me with this:icon_confused:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class bingo
{
public:int a[5][5];
void input();
void check();
void play();
void comp();
};
void bingo::input()//input a 5*5 matrix
{
int i,j,num;
cout<<"\n Enter numbers 1-25\n";
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
cin>>a[i][j];
}
endl;
}
}
void bingo::check()//no number 1-25 must be repeated
{ int error=0;
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
int num=a[i][j];
if(num==a[i][j+1])
{
error=1;
}
}
}
if(error>0)
{
cout<<"\n Number repeated\n";
cout<<"PLEASE START OVER\n";
cout<<"\a";
getch();
exit(0);
}
}
void bingo::play()
{
cout<<"\n START GAME\n";
for(int cal=1;cal<=25;cal++)//print input
{
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
cout<<a[i][j]<<" ";
}
cout<<"\n"<<"\n";
}
cout<<"\n Enter the number to be striked\n";
int num,j,k=0,diag=0;
cin>>num;
for(i=0;i<5;i++)//place 0 in place of num
{
for(j=0;j<5;j++)
{
if(num==a[i][j])
{
a[i][j]=0;
if((a[k][k]==0)&&(diag!=5))//check for diagnol elements
{
diag++;
k++;
if(diag==5)//if all the 5 elents are 0
cout<<"\n Row completed\n";
}
}
}
}
}
}
void main()
{
clrscr();
bingo b;
b.input();
b.check();
b.play();
}