ship hit game by sachin

PHOTO EMBED

Sat Feb 04 2023 15:23:51 GMT+0000 (Coordinated Universal Time)

Saved by @sachinM #cpp

#include <iostream>

using namespace std;

int main(){
 
 bool ships[3][4]={{0,1,0,1},{1,0,0,1},{1,0,1,0}};
int n=1,t=0,guess=0,maxship=1;

while (n!=0)
{
    cout<<"Enter cordinates of the ship row-(0-2),col-(0-3): ";
    int c,b;
    cin>>c>>b;
   
    if (ships[c][b]==1)
    {
        
        cout<<"You hit the ship"<<endl;
        t++;
        ships[c][b]=0;
        
        if (maxship>5)
    {
        cout<<"you guessed all the coordinates in the perfect number: "<<endl;
       break;
    }
    maxship++;
    }
    else
    {
        cout<<"nearly miss next try:"<<endl;
    }
    cout<<"You want to continue press 1 for exit=0: ";
    cin>>n;
    
    
    guess++;
}


cout<<"Your number of hit:"<<t<<endl;
cout<<"number of guesses:"<<guess;



        
    
}
content_copyCOPY