Skip to content

51Nod 2414 启蒙练习-图形输出2#

目录#

1. 题目描述#

1.1. Limit#

Time Limit: 1000 ms

Memory Limit: 131072 kB

1.2. Problem Description#

输入一个数,输出层图形,见下(图为的情况)

*
***
*****
*******

1.3. Input#

输入一个数


1.4. Output#

输出相应的图形


1.5. Sample Input#

5

1.6. Sample Output#

*
***
*****
*******
*********

1.7. Source#

2414 启蒙练习-图形输出2


2. 解读#

假设行号为 ,每一行输出 个符号

3. 代码#

#include <iostream>
using namespace std;

int main()
{
    long long n;
    // 读入n
    scanf("%lld", &n);
    // 输出图形
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2 * i + 1; j++) {
            printf("*");
        }
        printf("\n");
    }
}

联系邮箱:curren_wong@163.com

Github:https://github.com/CurrenWong

欢迎转载/Star/Fork,有问题欢迎通过邮箱交流。

Back to top