C语言中提示用户输入8行8列的数组和表示字符,绘制地图

运行效果:

Please input the picture of the wall:*

Please input your map: (1 0)

11111111
10000001
10000001
11110001
10000011
10000001
10000001
11111111

Now drawing the map...

********
*______*
*______*
****___*
*_____**
*______*
*______*
********
最好用最基础的代码编写

#include<stdio.h>
void main()
{
    int a[8][8],i,j;
printf("Please input the picture of the wall:*\n\nPlease input your map: (1 0)\n");
for(i=0;i<8;i++){
for(j=0;j<8;j++){
scanf("%1d",&a[i][j]);
}
}
printf("\nNow drawing the map...\n\n");
for(i=0;i<8;i++){
for(j=0;j<8;j++){
printf("%c",(a[i][j]==0)?'_':'*');
}
printf("\n");
}
}

请采纳

追问

谢谢呢 但是我想问下

(a[i][j]==0)?'_':'*' 是什么意思呀?

追答

问号是三目运算符。
语句一?语句二:语句三
如果语句一为真,则执行语句二否则执行语句三。
代码里这个是如果a[i][j]等于0就返回_否则返回*。

温馨提示:答案为网友推荐,仅供参考
相似回答