#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
const int S = 8;
int counter1 = 0;
void printBoard1(char[8][8]);
char board1[8][8] = { '\0' };
int main(){
int row = 3;
int column = 4;
for (int i = 0; i < S; ++i){
board1[i][column] = '*';
}
for (int j = 0; j < S; ++j){
board1[row][j] = '*';
}
//diagonal right top
for (int j = 1; j < 8 - column; j++)
{
board1[row - j][column + j] = '*';
}
//diagonal left bottom
for (int j = 1; j < column; j++){
board1[row + j][column - j] = '*';
}
//diagonal right bottom
for (int j = 1; j < 8 - column; j++){
board1[row + j][column + j] = '*';
}
//diagonal left top
for (int j = 1; j <= column; j++){
board1[row - j][column - j] = '*';
}
printBoard1(board1);
cin.get();
return 0;
}
void printBoard1(char board1[8][8])
{
for (int row = 0; row < S; ++row)
{
for (int col = 0; col < S; ++col)
{
cout << setw(3) << board1[row][col];
}
cout << '\n';
}
}
output:
* * *
* * *
* * *
* * * * * * * *
* * *
* * *
* * *
*
Post a Comment