题解 | #K形图案#
K形图案
https://www.nowcoder.com/practice/753cc2662d9949fe826a85f815db0ca4
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int k;
while (cin >> k)
{
for (int i = 0; i < 2*k+1; i++)
{
cout << "* ";
for (int j = 0; j < k; j++)
{
if (j < abs(k - i)) cout << "* ";
else cout << " ";
}
cout << endl;
}
}
return 0;
}
// 64 位输出请用 printf("%lld")
查看14道真题和解析