- 题目

- 思路
- 数学题,引入cmath计算即可
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int n,t1,t2;
scanf("%d",&n);
double a[n];
for(int i=0;i<n;i++){
scanf("%d %d",&t1,&t2);
a[i]=sqrt(t1*t1*1.0+t2*t2*1.0);
}
sort(a,a+n); //从低到高进行排序
printf("%.2lf",a[n-1]);
return 0;
}
本文介绍了一个使用C++解决数学问题的程序,主要功能是通过输入多个坐标点,利用cmath库计算每个点到原点的距离,并将距离值进行排序,最后输出离原点最远的点的距离。代码中运用了标准输入输出、cmath数学函数、数组和排序算法。

被折叠的 条评论
为什么被折叠?



