zoukankan      html  css  js  c++  java
  • 打印菱形

     1 //打印菱形
     2 #include <stdio.h>
     3 #include <stdlib.h>
     4 
     5 #define ROW 5
     6 
     7 
     8 int main()
     9 {
    10     int i, j;
    11     //打印前ROW行
    12     for(i = 1; i <= ROW; i++)
    13     {
    14         for(j = 1; j <= ROW+i-1; j++)
    15         {
    16             if(j > ROW-i)
    17                 printf("%c",4);
    18             else
    19                 printf(" ");
    20         }
    21         printf("
    ");
    22     }
    23 
    24     //后ROW-1行
    25     for(i = 1; i < ROW; i++)
    26     {
    27         for(j = 1;j <= 2*ROW-i-1; j++)
    28         {
    29             if(j > i)
    30                 printf("%c",4);
    31             else
    32                 printf(" ");
    33         }
    34         printf("
    ");
    35     }
    36 
    37     system("pause");
    38     return 0;
    39 }

  • 相关阅读:
    Gym
    博客搬家
    UVA
    UVA
    UVA
    UVA
    UVA
    UVA1589——xiangqi
    SDUSToj第十一次作业源代码格式问题
    【成长之路】【python】python基础3
  • 原文地址:https://www.cnblogs.com/cpsmile/p/4776527.html
Copyright © 2011-2022 走看看