//过会儿再编辑得简洁点。
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define nMine 10 // Number of mines
#define nRow 10
#define nCol 8
// "Mines" or "Not Mines" are marked by numbers.
// 9 for mines,
// and other numbers from 0 to 8 stands ...
// for the number of the 8 surrownding locations.
int main(void)
{
int MineLoc1D[nMine]={0};
int MineLoc2D[nRow+2][nCol+2]={0};
srand(time(NULL));
for(int p=0;p<nMine;p++)
{
MineLoc1D[p]=rand()%(nRow*nCol); // 1D
// Avoid overlap
for(int t=0;t<p;t++)
{
if(MineLoc1D[p]==MineLoc1D[t])
{
p--;
}