c 取读地图输入

1 char mat[60][60];
2 
3     scanf("%ld%ld",&n,&m);
4     for (i=0;i<n;i++)
5         scanf("%s",mat[i]);
6 //字符串不会读入' '和'
',
7 //这样做可以忽略输入中的空格和空行,c语言中字符串会忽略空格和空行,但字符却不会

如果需要对字符进行处理

char mat[60][60];
while (xx)
{
     scanf("%ld%ld",&n,&m);  
     for (i=0;i<n;i++)
     {
         scanf("%c",&c);
         for (j=0;j<m;j++)
         {
                 scanf("%c",&mat[i][j]);
                 if (mat[i][j]==xxx)
                 {
                          ……
                 }
         } 
     }  
}
原文地址:https://www.cnblogs.com/cmyg/p/7225921.html