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
|
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
using namespace std;
int main()
{
int np, x, y, xc=0, yc=0, n, ox[n]={}, oy[n]={}, j=0, k, oct, on;
string bp[12][12], bpp[12][12], p="*", pc="P", o="O";
srand(time(NULL));
xc=rand()%10;
yc=rand()%10;
bp[xc][yc]=pc;
cin>>on;
for(n=0;n<on;n++)
{
k=rand()%12;
if(k!=11)
{
do
{
oct=0;
j=rand()%12;
ox[n]=k;
oy[n]=j;
for(np=0;np>n;np++)
{
if((ox[n]==ox[np]&&oy[n]==oy[np])||(ox[n]==xc&&oy[n]==yc))
{
oct=1;
} }
}while(oct==1);
}
else
{
do
{
oct=0;
j=rand()%11;
ox[n]=k;
oy[n]=j;
for(np=0;np>n;np++)
{
if((ox[n]==ox[np]&&oy[n]==oy[np])||(ox[n]==xc&&oy[n]==yc))
{
oct=1;
}
}
}while(oct==1);
}
bp[k][j]=o;
}
cout<<"Pc = "<<xc<<","<<yc<<endl;
for(n=0;n<on;n++)
{
cout<<n<<" "<<ox[n]<<","<<oy[n]<<endl;
}
}
|