打印菱形

 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 }

原文地址:https://www.cnblogs.com/cpsmile/p/4776527.html