This is my 代码
#include <iostream>
using namespace std;
int is_z(int);
int main()
{
int n, a[110][110], s = 0, c = 0;
cin >> n;
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= n; j ++)
{
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= n; j ++)
{
if (is_z(a[i][j]))
{
s ++;
if ((!is_z(a[i - 1][j])) || (!is_z(a[i + 1][j])) || (!is_z(a[i][j - 1])) || (!is_z(a[i][j + 1])))
{
c ++;
}
}
}
cout << s << " " << c;
return 0;
}
int is_z(int a)
{
if (a <= 50) return 1;
else return 0;
}