题解 | #箭形图案#
箭形图案
https://www.nowcoder.com/practice/a6d1081e0c9a42f19e42ed6cd91556c1
#include<iostream> #include<cmath> using namespace std; int main() { int k; while (cin >> k) { for (int i = 0; i < 2*k+1; i++) { for (int j = 0; j < 2 * k + 1; j++) { if (j < abs(2 * k - 2 * i)) cout << " "; } cout << string(k+1 - abs(k - i), '*') << endl; } } return 0; }