1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
/*
Abdul quddos
bte-fa07-003-8c
*/
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include <windows.h>
using namespace std;
int main()
{
// clrscr();
int i,j,x,x1,l2,y,t,r,x2,i1,j1,l=0;
char a[8][8]={'o','m','o','o','m','o','o','m',
'm','o','o','o','m','o','m','o',
'o','o','m','o','o','m','m','o',
'm','o','o','m','o','o','m','o',
'o','o','o','m','o','m','o','m',
'o','m','o','m','o','o','m','m',
'o','m','o','m','o','o','o','m',
'm','o','m','m','o','m','m','o'};
char s[]={"abdul quddos"};
char s1[15];
cout<<"Enter Password :";
do{
gets(s1);
l2=strcmp(s1,s);
cout<<"Invalid Password "<<endl;
getch();
cout<<"Enter valid password :";
goto tag4;
}while(l2!=0)
else if(l2==0)
{
cout <<" Login successfully "<<endl;
}
cout<<"\t\t\t\tMINESWEEPER\n\n\t\t\t\t BY\n\n\t\t\t\tABDUL QUDDOS\n\n\n\n";
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
cout<<"\t"<<a[i][j];
}
cout<<"\n\n";
}
tag:
tag2:
cout<<"\nenter your location : ";
cout<<"\nenter row : ";
cin>>x;
if(x<0||x>8)
{
cin.clear();
cin.ignore();
cout<<"\nInvalid input";
getch();
goto tag2;
}
tag3:
cout<<"enter column :";
cin>>y;
if(y<0||y>8)
{
cin.clear();
cin.ignore();
cout<<"\nInvalid input";
getch();
goto tag3;
}
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
if(i==x && j==y)
{
if(a[i][j]=='m')
{
cout<<"\n\nYour value is : "<<a[i][j]<<" Game end";
break;
}
else if(a[i][j]=='o')
{
a[i][j]=x1;
l=0;
if((i==0)&&(j>0&&j<8)) //row is 0 and column is (1-7)
{
for(t=i;t<=i+1;t++)
{
for(r=j-1;r<=j+1;r++)
{
if(a[t][r]=='m')
{
l++;
}
}
}
}
else if((i>0&&i<8)&&(j==0)) //row is(1-7) and column is 0
{
for(t=i-1;t<=i+1;t++)
{
for(r=j;r<=j+1;r++)
{
if(a[t][r]=='m')
{
l++;
}
}
}
}
//
// After this point I gave up on formatting...
//
else if(i==0&&j==0) //row is 0 and column is 0
{
for(t=i;t<=i+1;t++)
{
for(r=j;r<=j+1;r++)
{
if(a[t][r]=='m')
{
l++;
}
}
}
}
else if((i>0&&i<7)&&(j>0&&j<7)) //row(1-6) and column (1-6)
{
for(t=i-1;t<=i+1;t++)
{
for(r=j-1;r<=j+1;r++)
{
if(a[t][r]=='m')
{
l++;
}
}
}
}
else if(i==7&&j==7) //row is 7 and column is 7
{
for(t=i-1;t<=i;t++)
{
for(r=j-1;r<=j;r++)
{
if(a[t][r]=='m')
{
l++;
}
}
}
}
else if(i==7&&j>0) //row is 7 and column is greater than 0
{
for(t=i-1;t<=i;t++)
{
for(r=j-1;r<=j+1;r++)
{
if(a[t][r]=='m')
{
l++;
}
}
}
}
else if(i>0&&j==7) //row is greater than 0 and column is 7
{
for(t=i-1;t<=i+1;t++)
{
for(r=j-1;r<=j;r++)
{
if(a[t][r]=='m')
{
l++;
}
}
}
}
for(i1=0;i1<8;i1++)
{
for(j1=0;j1<8;j1++)
{
if(x1==a[i1][j1])
{
for( r=48;r<57;r++)
{
x2=r;
if(l+48==x2)
{
a[x][y]=r;
cout<<"\t"<<a[i1][j1];
}
}
}
else
cout<<"\t"<<a[i1][j1];
}
cout<<"\n\n";
}
}
goto tag;
}
}
}
while( !GeatAsyncKeyState( VK_ESCAPE ) );
return 0;
}
|