当前位置: 代码迷 >> 综合 >> soj - 1815 - 计算两点间的距离
  详细解决方案

soj - 1815 - 计算两点间的距离

热度:20   发布时间:2024-01-10 13:48:32.0

题意:请用类描述顶点信息,输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。

题目链接:http://soj.me/1815

——>>小心转换为浮点型

#include <cstdio>
#include <algorithm>
#include <iomanip>using namespace std;const int maxn = 100 + 10;
int n;class person
{private:int sum, minn, maxn;public:void clear(){sum = 0;minn = 21474836;maxn = -2147483;}void add(int s){sum += s;if(s < minn) minn = s;if(s > maxn) maxn = s;}double get(){return (double)(sum - minn - maxn) / (n-2);}
}a[maxn];int main()
{int T, m, i, j, b;scanf("%d", &T);while(T--){scanf("%d%d", &n, &m);for(i = 0; i < m; i++) a[i].clear();for(i = 0; i < n; i++)for(j = 0; j < m; j++){scanf("%d", &b);a[j].add(b);}for(i = 0; i < m; i++) printf("%.2lf\n", a[i].get());}return 0;
}