题解 | #菱形图案#
菱形图案
https://www.nowcoder.com/practice/8b935f8ffe99445dbd42494febd13e45
#include <iostream> using namespace std; #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 < k+1; j++) { if (j < abs(k - i)) cout << " "; else cout << "* "; } cout << endl; } } return 0; } // 64 位输出请用 printf("%lld")