首页 > 解决方案 > 编写一个基本的半金字塔图案程序

问题描述

尝试了一些基本模式

试图获得模式

1
2 4
3 6 12
4 8 16 32

到目前为止,试图找到正确的序列,我的想法是需要另一个变量让我们说 num,并且需要为 num 创建一个序列以最终打印 num

#include <stdio.h>
int main()
{
    int rows = 0  , i, j , num,num2;


   do{
        printf("please enter the number of rows: ");
       scanf("%d",&rows);
    }while(rows <=2 );
    printf("printing a half pyramid of %d rows", rows);
    printf("\n");
     for( i = 1; i <=rows; ++i) {
        for (j = 1; j <= i; ++j ) {

            printf("%d ",  );


        }
       printf("\n");

    }
    return 0;
}

无法弄清楚顺序

标签: cloopsfor-loopwhile-loopdo-while

解决方案



推荐阅读