3.代码
#include<bits/stdc++.h>
using namespace std;
int n,c,s,a[105][105];
bool is_zl(int x){
if(x<=50)return true;
return false;
}
int main(){
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++){
a[0][i]=255;
}
for(int i=1;i<=n;i++){
a[i][0]=255;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(is_zl(a[i][j])){
s++;
if(!is_zl(a[i-1][j]) || !is_zl(a[i+1][j]) || !is_zl(a[i][j-1]) || is_zl(a[i][j+1])){
c++;
}
}爆
}
}
cout<<s<<' '<<c;
return 0;
}
©®™℗