题解 | #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")

全部评论

相关推荐

积极的小学生不要香菜:你才沟通多少,没500不要说难
点赞 评论 收藏
分享
06-23 11:43
门头沟学院 Java
allin校招的烤冷...:我靠,今天中午我也是这个hr隔一个星期发消息给我。问的问题还是一模一样的😅
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务