*
***
*****
*******
*****
***
*
// 這幾天奇怪了,要輸出菱形程序的人好多。
#include <iostream>
#include <cmath>
int main() {
const int row = 5; // 5行,對于行對稱的,使用絕對值來做比較好
const int max = row / 2 + 1;
for (int i = -max + 1; i < max; ++i) {
for (int j = 0; j < abs(i); ++j, std::cout << " ");
for (int j = 0; j < (max - abs(i)) * 2 - 1; ++j, std::cout << "*");
std::cout << std::endl;
}
return 0;
}