可以通过循环语句和预先定义的图形模板来实现自定义的图形。
具体实现方法可以参考如下程序:
#include
#defineWIDTH9//宽也即列数
#defineHEIGHT7//高也即行数
#defineCHAR"*"
intModal[HEIGHT][WIDTH]=//定义形状的模板
{
{0,1,1,1,0,1,1,1,0},
{1,0,0,0,1,0,0,0,1},
{1,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,1,0},
{0,0,1,0,0,0,1,0,0},
{0,0,0,1,0,1,0,0,0},
{0,0,0,0,1,0,0,0,0}
};
voidmain()
{
inti,j;
for(i=0;i