![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
C语言编程题目——求解
1
121
12321
1234321
2. 打印以下图案:
1234321
12321
121
1
3.打印以下图形:
+— —+
| |
| |
+— —+
4.打印以下图形:
+— —+
| |
| |
| |
+— —+ 展开
#include<stdio.h>
#include<math.h>
void main()
{
int i,j,k;
for(i=1;i<=4;i++)
{
for(k=4-i;k>0;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(j=i-1;j>=1;j--)
{
printf("%d",j);
}
printf("\n");
}
}
#include<stdio.h>
#include<math.h>
void main()
{
int i,j,k;
for(i=4;i>=1;i--)
{
for(k=0;k<=4-i;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(j=i-1;j>=1;j--)
{
printf("%d",j);
}
printf("\n");
}
}
#include<stdio.h>
void main()
{ int i,j;
char a[4][4]={{'+','-','-','+'},{'|',' ',' ','|'},{'|',' ',' ','|'},{'+','-','-','+'}};
for(i=0;i<=3;i++)
{for(j=0;j<=3;j++)
{printf("%c",a[i][j]);}
printf("\n");}
}
#include<stdio.h>
void main()
{ int i,j;
char a[5][4]={{'+','-','-','+'},{'|',' ',' ','|'},{'|',' ',' ','|'},{'|',' ',' ','|'},{'+','-','-','+'}};
for(i=0;i<=4;i++)
{for(j=0;j<=3;j++)
{printf("%c",a[i][j]);}
printf("\n");}
}