char map[9][9]={{'1','1','1','1','1','1','1','1','1'},
{'1','2','2','2','1','1','1','1','1'},
{'1','2','2','2','1','1','1','1','1'},
{'1','2','2','2','1','1','1','2','1'},
{'1','1','1','2','1','1','1','2','1'},
{'1','1','1','2','2','2','2','2','1'},
{'1','1','2','2','2','1','2','2','1'},
{'1','1','2','2','2','1','1','1','1'},
{'1','1','1','1','1','1','1','1','1'}};
将此数组转换成:
int map[9][9]={{1,1,1,1,1,1,1,1,1},
{1,2,2,2,1,1,1,1,1},
{1,2,2,2,1,1,1,1,1},
{1,2,2,2,1,1,1,2,1}, {1,1,1,2,1,1,1,2,1},
{1,1,1,2,2,2,2,2,1},
{1,1,2,2,2,1,2,2,1},
{1,1,2,2,2,1,1,1,1},
{1,1,1,1,1,1,1,1,1}};
最好弄一个完整的C程序
#include <stdlib.h>
#include <stdio.h>
void main()
{
char map[9][9]={{'1','1','1','1','1','1','1','1','1'},
{'1','2','2','2','1','1','1','1','1'},
{'1','2','2','2','1','1','1','1','1'},
{'1','2','2','2','1','1','1','2','1'},
{'1','1','1','2','1','1','1','2','1'},
{'1','1','1','2','2','2','2','2','1'},
{'1','1','2','2','2','1','2','2','1'},
{'1','1','2','2','2','1','1','1','1'},
{'1','1','1','1','1','1','1','1','1'}};
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
printf("%c",map[i][j]);
printf("/n");
}
int bb[9][9]={0};
for(int i=0;i<9;i++)
for(int j=0;j<9;j++)
{
printf("%c",map[i][j]);
bb[i][j]=atoi(map[i][j]);
}
// printf("%d",bb);
}
我这样提示有错误:
passing 'char' to argument 1 of 'atoi(const char *)' lacks a cast
二维字符数组转换成二维整形数组
最新推荐文章于 2024-04-18 22:35:02 发布