Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Final Assignment of Discrete Structures

Name:
Taimoor Akmal
Submitted to:
Sir Usman Akram

Section:
A

Roll #:
097

Dated: 12-01-2010
#include<iostream.h>

#include<conio.h>

int main()

cout<<"\n\n\t\tMINESWEEPER : ";

cout<<"\n\n\t\tENTER 'M' FOR MINES AND 'O' FOR OTHER \n\n";

char s1[8][8];

int r,c,i;

int x,y,z=0;

for(r=0; r<9; r++)

for(c=0; c<9; c++)

cout<<"\nEnter the r = "<<r <<",c = "<<c<<" = ";

cin>>s1[r][c];

cout<<"\n\n";

for(c=0; c<9; c++)

cout<<" "<<c<<"";

cout<<"\n"<<0;

Dated: 12-01-2010
for(r=0; r<9; r++)

for(c=0; c<9; c++)

cout<<" "<<s1[r][c];

if(c==8)

cout<<"\n\n";

cout<<r+1;

for(i=0; i<9; i++)

cout<<"\n\nEnter X = ";

cin>>x;

cout<<"Enter Y = ";

cin>>y;

if(s1[x][y]=='o')

if(s1[x-1][y]=='m')

z++;

if(s1[x+1][y]=='m')

z++;

Dated: 12-01-2010
if(s1[x][y-1]=='m' && y!=0)

z++;

if(s1[x][y+1]=='m' && y+1<9)

z++;

if(s1[x+1][y+1]=='m' && y+1<9)

z++;

if(s1[x-1][y-1]=='m' && y!=0)

z++;

if(s1[x-1][y+1]=='m'&& y+1<9)

z++;

if(s1[x+1][y-1]=='m' && y!=0)

z++;

cout<<"\n\n";

for(c=0; c<9; c++)

cout<<" "<<c<<"";

cout<<"\n"<<0;

for(r=0; r<9; r++)

for(c=0; c<9; c++)

if(x==r && y==c)

cout<<" "<<z;

Dated: 12-01-2010
else

cout<<" "<<s1[r][c];

if(c==8)

cout<<"\n\n";

cout<<r+1;

if(s1[x][y]=='m')

cout<<"\nGame Over\n"<<"there is mine\n";

cout<<s1[x][y];

else

cout<<"\nNumber of mines :"<<z;

z=0;

getch();

return 0;

Reference:
Taken from Wikipedia.

Dated: 12-01-2010

You might also like