Commit 9bce2395 authored by Michael's avatar Michael

michael.davityan:exercise_05_24v10

parent 3f7a5c7d
Error 1: wrong number(must be odd number from 1->19).
Error 1: wrong size value(must be odd number from 1->19).
Error 1: wrong number(must be odd number from 1->19).
Error 1: wrong size value(must be odd number from 1->19).
Error 1: wrong number(must be odd number from 1->19).
Error 1: wrong size value(must be odd number from 1->19).
......@@ -5,20 +5,20 @@
int
main()
{
int lineCount;
int rhombusSize;
if (::isatty(STDIN_FILENO)) {
std::cout << "insert line count(must be odd number from 1->19): ";
std::cout << "insert rhombus size(must be odd number from 1->19): ";
}
std::cin >> lineCount;
if (lineCount % 2 == 0 || lineCount < 1 || lineCount > 19) {
std::cerr << "Error 1: wrong number(must be odd number from 1->19).\n";
std::cin >> rhombusSize;
if (rhombusSize % 2 == 0 || rhombusSize < 1 || rhombusSize > 19) {
std::cerr << "Error 1: wrong size value(must be odd number from 1->19).\n";
return 1;
}
const int ROW_LIMIT = lineCount / 2;
for (int row = -ROW_LIMIT; row <= ROW_LIMIT; ++row) {
const int columnLimit = ROW_LIMIT - std::abs(row);
for (int column = -ROW_LIMIT; column <= columnLimit; ++column) {
std::cout << (column < -columnLimit ? " " : "*");
const int rowLimit = rhombusSize / 2;
for (int row = -rowLimit; row <= rowLimit; ++row) {
const int starStart = rowLimit - std::abs(row);
for (int column = -rowLimit; column <= starStart; ++column) {
std::cout << (column < -starStart ? " " : "*");
}
std::cout << std::endl;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment