Untitled

 avatar
unknown
plain_text
2 years ago
2.2 kB
4
Indexable
#include <iostream>
#include <cstdlib>
using namespace std;

#define N 10
#define MIN_VALUE 0
#define MAX_VALUE 9

void Player1_board();
void Player2_board();



int main()
{
    Player1_board();
    Player2_board();


    return 0;
}

void Player1_board()
{
    std::cout <<"Player1 board:"<<endl<<endl;
    int matrix[N][N]={0};
    std::cout << "  ";
    for (int i = 0; i < N; i++)
    {
        std::cout << i;
        if (i != N - 1)std::cout << "|";
        else std::cout << endl;
    }

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N - 1; j++)
        {
            if (j == 0)
            {
                std::cout << i << "| ";
            }
            std::cout << "| ";
            if (j == N - 2)
                std::cout << endl;
        }
    std::cout<<endl;
}

void Player2_board()
{
    std::cout <<"Player2 board:"<<endl<<endl;
    int matrix[N][N]={0};
    std::cout << "  ";
    for (int i = 0; i < N; i++)
    {
        std::cout << i;
        if (i != N - 1)std::cout << "|";
        else std::cout << endl;
    }

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N - 1; j++)
        {
            if (j == 0)
            {
                std::cout << i << "| ";
            }
            std::cout << "| ";
            if (j == N - 2)
                std::cout << endl;
        }
    std::cout<<endl;
}

/*
void attack()
{
    int row, column;
    for(int i=0;i<10;++i)
    {
      row=rand()%10;
      column=rand()%10;
      matrix[row][column]=1;

    }

    for(int i=0;i<10;++i)
    {
      for(int j=0;j<10;++j)
      {
        cout<<matrix[i][j];
      }
      cout<<endl;
     }

     while(true)
     {
       cout << "Enter number of the row:" << endl;
       cin >> row;
       cout << "Enter number of the column:" << endl;
       cin >> column;

     }
}
*/

void placeOfSubmarine2()
{
    int col,row;
    srand((unsigned)time(NULL)); // Initialization of random
    int value = MIN_VALUE + (rand() % (MAX_VALUE –MIN_VALUE));
    {
        std::cout<<"1"<<endl;
    }
}
Editor is loading...