Beruflich Dokumente
Kultur Dokumente
/**************************************************************/
#include <cstdlib>
#include <iostream>
bool submarine=false; bool carrier=false; bool destroyer=false; bool ship=false; //booleen operaters
cout<<"\n";
cout<<" D = you have hit the small destroyer \n"; // introduction to game, what the different
symbols mean
int placeB[10][10]={{1,2,2,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,3,3,3,0,0,0,0},
{0,0,0,0,0,0,0,0,6,0},
{0,0,0,0,0,0,0,0,6,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0}};
int placeA[10][10]={{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0}};
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"\n";
int x,y;
int z=0;
for(y=0;y<10;y++)
cout<<"\n";
for(x=0;x<10;x++)
{ // printing out static arrays in for loop also assiging hit miss and unchosen varibales
to input
if(placeA[x][y]==4)
cout<<"M";
else if(placeA[x][y]==8){
cout<<"C";
else if(placeA[x][y]==7){
cout<<"D";
else if(placeA[x][y]==6){
cout<<"S";
else if(placeA[x][y]==5){
cout<<"A";
else if(placeA[x][y]==0)
cout<<" ~";
cout<<"\n";
cout<<"\n";
cout<<"select (Row)X \n";
cin>>x;
cin>>y;
cout<<"\n";
cout<<"\n";
placeA[x][y]=8; }
cout<<"\n";
cout<<"\n";
placeA[x][y]=7; }
else if (x==3&&y==5||x==4&&y==5||x==5&&y==5){
cout<<"\n";
cout<<"\n";
placeA[x][y]=6; }
else if (x==8&&y==6||x==8&&y==7){
cout<<"\n";
cout<<"\n";
placeA[x][y]=5; }
else{
cout<<"\n";
cout<<"\n";
placeA[x][y]=4;
carrier=true;
if( x==1&&y==0,x==2&&y==0){
cout<<"\n";
destroyer=true;
cout<<"\n";
submarine=true;
if(x==8&&y==6,x==8&&y==7){
cout<<"\n";
ship=true;
}
cout<<" \n YOU HAVE SUNK ALL THE ENEMIES SHIPS CONGRATS \n"; //once it is true do this
system("PAUSE");
return EXIT_SUCCESS;