Pagini recente » Cod sursa (job #3140681) | Cod sursa (job #746332) | Cod sursa (job #1822636) | Cod sursa (job #2413817) | Cod sursa (job #636817)
Cod sursa(job #636817)
#include <fstream>
#include <iomanip>
#include <cstdlib>
using namespace std;
ifstream fin("minesweeper.in");
ofstream fout("minesweeper.out");
int N , M , D[16][16] , nr , timp , t , nm;
void f(int x,int y)
{
nr = 0;
while(nr!=nm)
{
timp++;
if(D[x][y]==1) D[x][y] = 2 , nr++;
else
if(D[x][y]==2) D[x][y] = 0 , nr--;
else
D[x][y]++;
x = rand() % N + 1 ,y = rand()%M + 1;
}
for(x=1;x<=N;++x)
for(y=1;y<=M;++y)
D[x][y] = 0;
}
int main()
{
fin>>N>>M;
nm = N*M;
for(int i=1;i<=100;++i)
f(rand()%N + 1 ,rand()%M+1);
fout<<fixed<<setprecision(6)<<(double)timp/100;
return 0;
}