• 习题4-9 打印菱形图案


     1 #include<stdio.h>
     2 
     3 int main(void)
     4 {
     5     int n;
     6 
     7     scanf_s("%d", &n);
     8 
     9     for (int i = 1; i <= n / 2; i++)
    10     {
    11         for (int j = i; j <= n / 2; j++)
    12         {
    13             printf("  ");
    14         }
    15         for (int j = 1; j <= i * 2 - 1; j++)
    16         {
    17             printf("* ");
    18         }
    19         printf("
    ");
    20     }
    21 
    22     for (int i = 1; i <= n; i++)
    23     {
    24         printf("* ");
    25     }
    26     printf("
    ");
    27 
    28     for (int i = 1; i <= n/2; i++)
    29     {
    30         for (int j = i; j <= i * 2 - 1; j++)
    31         {
    32             printf("  ");
    33         }
    34         for (int j = 1; j <= n - i * 2; j++)
    35         {
    36             printf("* ");
    37         }
    38         printf("
    ");
    39     }
    40 
    41     return 0;
    42 }

  • 相关阅读:
    后台性能测试不可不知的二三事
    linux下操作mysql
    loadrunner scripts
    反射
    java 读取json
    java 多线程
    python_day11
    python爬虫
    python_day10
    python_day9
  • 原文地址:https://www.cnblogs.com/2018jason/p/10905385.html
Copyright © 2020-2023  润新知