Commit be7c6fbe by Karine

Exercise_05_24, Version2

parent fdddfabd
#include <iostream>
#include <cmath>
int
main()
......@@ -14,36 +15,20 @@ main()
}
std::cout << std::endl;
int space = row - 1;
for (int i = 1; i <= row; i++) {
for (int j = 1; j <= space; j++) {
std::cout << " ";
}
space--;
for (int j = 1; j <= 2 * i - 1; j++) {
std::cout << "*";
}
std::cout << std::endl;
}
space = 1;
for (int i = 1; i <= row; i++) {
for (int j = 1;j <= space; j++) {
std::cout << " ";
}
space++;
for (int j = 1; j <= 2 * (row - i) - 1; j++) {
std::cout << "*";
}
row -= 1;
for(int i = -row; i <= row; ++i) {
for(int j = -row; j <= row; ++j) {
if( std::abs(i) + std::abs(j) <= row) {
std::cout << "*";
}
else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
}
Enter the odd count of rows (from 1 to 19):
*
***
*****
*******
*********
***********
*
***
*****
*******
*********
***********
*************
***********
*********
*******
*****
***
*
***********
*********
*******
*****
***
*
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