题目描述
- 数组的下方区域。(曼哈顿距离解法)
曼哈顿距离
C++ 代码
#include<iostream>
#include<cmath>
using namespace std;
const int N = 12;
int main()
{
char op;double num;
double sum = 0;
cin >> op;
double center_X = 5.5;int center_Y = 11;
for(int i = 0;i < N;i++)
{
for(int j = 0;j < N;j++)
{
cin >> num;
if(double(fabs(center_X - j) + center_Y - i) < 5.5) sum += num;
}
}
printf("%.1lf",op == 'S'?sum : sum / 30);
return 0;
}