1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <string>
/*
row = 1: * O O O O O * * * * * O * * * * * O O O O O * 1,5,5,1,5,5,1
row = 2: * * O O O O * * * * O O O * * * * O O O O * * 2,4,4,3,4,4,2
row = 3: * * * O O O * * * O O O O O * * * O O O * * * 3,3,3,5,3,3,3
row = 4: * * * * O O * * O O O O O O O * * O O * * * * 4,2,2,7,2,2,4
row = 5: * * * * * O * O O O O O O O O O * O * * * * * 5,1,1,9,1,1,5
*/
int main()
{
std::string line, part[7];
for(int row = 0; row < 5; row++)
{
part[0].assign(row + 1, '*');
part[1].assign( 5 - row, 'O');
part[2].assign( 5 - row, '*');
part[3].assign( 2 * row + 1, 'O');
part[4] = part[2];
part[5] = part[1];
part[6] = part[0];
line.clear();//line = " ";
for(int col = 0; col < 7; col++)
{
line += part[col];;
}
std::cout << line << '\n';
}
return 0;
}
|