Hi everyone:)
I am still not able to complete this:(
can anyone please help!!!
#include<iostream.h>
#include<conio.h>
class bingo
{
public:int a[5][5];
void input();
void play();
};
void bingo::input()//input a 5*5 matrix
{
int i,j,num,check=0,l,m;
cout<<"\n Enter numbers 1-25\n";
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
cin>>a[i][j];
num=a[i][j];
for(l=0;l<5;l++)//check if number has repeated
{
for(m=0;m<5;m++)
{
if(a[l][m]==num)
check++;
if(check==2)
{
cout<<"\n Number repeated\nStart again!\n";
getch();
exit(0);
}
}
}
}
}
}
void bingo::play()
{
int i,j,cal;
cout<<"\n START GAME\n";
for(cal=1;cal<=25;cal++)//print input
{
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
cout<<a[i][j]<<" ";
}
cout<<"\n"<<"\n";
}
cout<<"\n Enter the number to be striked\n";
int ele,diag1=0,diag2=0,row1=0,row2=0,row3=0,row4=0,row5=0;
int col1=0,col2=0,col3=0,col4=0,col5=0,game=01;
cin>>ele;
for(i=0;i<5;i++)//place 0 in place of ele
{
for(j=0;j<5;j++)
{
if(ele==a[i][j])
{
a[i][j]=0;
if(a[i][j]==0 && i==j)//principle diagonal
{
diag1++;
if(diag1==5)
cout<<"\n Row completed\n";
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
switch(i) //checking rows
{
case 0: if(a[i][j]==0)
{
row1++;
if(row1==5)
cout<<"\n Row completed\n";
j++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
case 1: if(a[i][j]==0)
{
row2++;
if(row2==5)
cout<<"\n Row completed\n";
j++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
case 2:if(a[i][j]==0)
{
row3++;
if(row3==5)
cout<<"\n Row completed\n";
j++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
case 3:if(a[i][j]==0)
{
row4++;
if(row4==5)
cout<<"\n Row completed\n";
j++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
case 4:if(a[i][j]==0)
{
row5++;
if(row5==5)
cout<<"\n Row completed\n";
j++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
default: break;
}
switch(j)//checking for columns
{
case 0:if(a[i][j]==0)
{
col1++;
if(col1==5)
cout<<"\n Row completed\n";
i++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
case 1:if(a[i][j]==0)
{
col2++;
if(col2==5)
cout<<"\n Row completed\n";
i++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
case 2:if(a[i][j]==0)
{
col3++;
if(col3==5)
cout<<"\n Row completed\n";
i++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
case 3:if(a[i][j]==0)
{
col4++;
if(col4==5)
cout<<"\n Row completed\n";
i++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
case 4:if(a[i][j]==0)
{
col5++;
if(col5==5)
cout<<"\n Row completed\n";
i++;
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
break;
default: break;
}
}
}
}
i=0;j=4;//checking for the diagonal that's remaining
while(i!=4 && j!=0)
{
if(a[i][j]==0)
{
diag2++;
if(diag2==5)
cout<<"\n Row completed\n";
i++;j--;
}
game++;
if(game==5)
cout<<"\n Congo!!!!\nGame completed\n";
}
}
}
void main()
{
clrscr();
bingo b;
b.input();
b.play();
}