POJ 2677 肿瘤检测 解题报告
POJ 2677 肿瘤检测 解题报告
编号:2677
考查点:简单计算题
思路: 面积和周长一起算比较好些.水题
提交情况: 一次AC..
Source Code:
#include <iostream>
using namespace std;
int num[100][100];
bool Search(int i,int j,int n)
{
if (i==0||j==0||i==n-1||j==n-1)
return true;
if (num[i+1][j]>50 || num[i-1][j]>50 || num[i][j-1]>50 || num[i][j+1]>50)
return true;
return false;
}
int main()
{
int n;cin>>n;
int area = 0;
int len = 0;
memset(num,0,sizeof num);
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
cin>>num[i][j];
}
}
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
if (num[i][j]<51)
{
area++;
if (Search(i,j,n))
{
len++;
}
}
}
}
cout<<area<<" "<<len;
return 0;
}
using namespace std;
int num[100][100];
bool Search(int i,int j,int n)
{
if (i==0||j==0||i==n-1||j==n-1)
return true;
if (num[i+1][j]>50 || num[i-1][j]>50 || num[i][j-1]>50 || num[i][j+1]>50)
return true;
return false;
}
int main()
{
int n;cin>>n;
int area = 0;
int len = 0;
memset(num,0,sizeof num);
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
cin>>num[i][j];
}
}
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
if (num[i][j]<51)
{
area++;
if (Search(i,j,n))
{
len++;
}
}
}
}
cout<<area<<" "<<len;
return 0;
}
总结: SHUI!
By Ns517
Time 09.02.26