二维数组功能好强大,打印各种图形无压力,比for循环好理解,此代码在Xcode上运行出来是什么? 复制到Xcode上就知道了!
#include<stdio.h>
int main(){
int a;
while (1)
{
printf("请在键盘上输入一个数字:\n");
scanf("%d",&a);
int arr[5][20]={{1,0,0,0,0,1,1,1,0,0,1,0,0,0,1,0,0,1,1,1},{1,0,0,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,0},{1,0,0,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,1,1},{1,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0},{1,1,1,0,0,1,1,1,0,0,0,0,1,0,0,0,0,1,1,1}};
for (int i=0;i<5;i++) {
for (int j=0;j<20;j++) {
if (0==arr[i][j]) {
printf(" ");
}
else
{
printf("%d",a);
}
}
printf("\n");
}
}
return 0;
} |
|