全WA求助,暴力代码,short没有溢出(改int也一样)
查看原帖
全WA求助,暴力代码,short没有溢出(改int也一样)
1074084
asd890123楼主2024/3/16 21:28
#include <cstdio>
#include <cstring>

signed main(){
    
    short x,y,ans=0;
    char map[505][505];
    
    scanf("%hd%hd\n",&x,&y);
    memset(map,' ',sizeof(map));
    for (short i=1;i<=x;i++,getchar())
        for (short j=1;j<=y;j++)
            map[i][j] = getchar();
    for (short i=1;i<=x;i++)
        for (short j=1;j<=y;j++)
            if (map[i][j] == '0' && map[i-1][j] == '*' && map[i+1][j] == '*' && map[i][j-1] == '*' && map[i][j+1] == '*')
                ans++;
    printf("%hd",ans);
    
    return 0;
}
2024/3/16 21:28
加载中...