#include #include #include #include #include #include #include #include #include #define DN 15 #define LB 10 #define SM "MISSED" #define HT 0 #define BT 1 using namespace std; int dx[]={0,1}; int dy[]={1,0}; map shipLenght; vector shipTypes; class Board { private: map shots; bool isShot[DN][DN]; string type[DN][DN]; public: bool validate(int x,int y) { if(x<1 || y<1 || x>LB || y>LB) return 0; return 1; } Board() { for(int i=1; i<=LB; ++i) for(int j=1; j<=LB; ++j) { isShot[i][j]=0; type[i][j]=SM; } for(int i=0; i1) return 0; for(int i=0; isetShip(x,y,o,shipTypes[i])) { x=rand()%LB+1; y=rand()%LB+1; o=rand()%2; } cout<>res; if(res=="HIT") { int ok=1; for(int d=0; d<4 && ok; ++d) { int ii=i+xx[d],jj=j+yy[d]; for(;b->validate(ii,jj);ii+=xx[d],jj+=yy[d]) { cout<>res; if(res==SM) break; if(res.find("SANK")!=string::npos) { ok=0; break; } } } } } }