这道题这么写哪里错了

import java.util.Scanner;

public class LakeCounting {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int p=0;
        int N = in.nextInt();
        int M = in.nextInt();
        boolean b[][] = new boolean[N][M];
        for(int i = 0;i< N;i++)
        {
            for(int j =0;j<M;j++)
            {
                byte s = in.nextByte();    
                char c= (char)s;
                if(c=='W')
                    b[i][j]=true;
                else
                    b[i][j]=false;
            }
        }
        for(int i =1;i<N-1;i++)
        {
            for(int j=1;j<M-1;j++)
            {
                if(b[i][j]==true&&b[i-1][j]==true&&b[i+1][j]==true&&b[i][j-1]==true&&b[i][j+1]==true)
                p++;    
            }
        }
        System.out.print(p);
        in.close();
    }

}

全部评论

相关推荐

小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务