哈弗哈


私信TA

用户名:jianchi1314

访问量:1286

签 名:

Yesterday is gone tomorrow is yet to come and all I have is today so today is a gift

等  级
排  名 3710
经  验 1783
参赛次数 0
文章发表 4
年  龄 0
在职情况 学生
学  校 长安大学
专  业

  自我简介:

#include<stdio.h>
void print(int a, int h, int n)//h是行数,n是个数,a是每一行第一个数
{
    int i;
    for(i = 1; i <= n; ++i){
        printf("%d%c", a, i<n?' ':'\n');//先输出后加
        a+=(i+h);//一次性加好
    }
}
int main()
{
    int n, a = 1, b;
    scanf("%d", &n);
    b = n;
    while(n){
        a+=(b-n);
        print(a, b-n+1, n);
        n--;
    }
return 0;
}


 

0.0分

3 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区