Masalaning dasturi:
#include
#include
using namespace std;
int main() {
int n,l;
cout<<"saper o`yini o'lchamini kiriting";
cin>>n; l=n/2.;
bool m[n+2][n+2];
for(int i=0; i<=n+1; i++){
for(int j=0; j<=n+1; j++){
m[i][j] = false;
}
}
srand(time(0));
int x, y;
for(int i=1; i<=l; i++){
do{
x = rand() % n + 1;
y = rand() % n + 1;
}while(m[x][y]);
m[x][y] = true;
}
int xCount = n*n;
while(xCount != 0){
cin >> x >> y;
if(m[y][x]){
cout << "fail" << endl;
goto L1;
}xCount--;cout<<"0"<
if (xCount == 0){cout << "win" << endl;}
L1: cout<<" ";for(int i=1; i<=n; i++)cout<
for(int i=1; i<=n; i++){cout<<" "<
for(int j=1; j<=n; j++){
cout << m[i][j]<<" ";
}
cout << endl;
}
return 0;
}
Laboratoriya mashg’uloti 13.1
Do'stlaringiz bilan baham: |