为什么最后一个测试节点会出现误差?
查看原帖
为什么最后一个测试节点会出现误差?
717932
sun786330楼主2025/1/3 23:59
#include<bits/stdc++.h>
using namespace std;
double work(int x1,int y1,int x2,int y2){
	return sqrt(pow((x1-x2),2)+pow((y1-y2),2));
}
int main(){
	double x1,y1,x2,y2,x3,y3;
	cin>>x1>>y1>>x2>>y2>>x3>>y3;
	double a=work(x1,y1,x2,y2);
	double b=work(x1,y1,x3,y3);
	double c=work(x2,y2,x3,y3);
	cout<<fixed<<setprecision(2)<<a+b+c;
	return 0;
}
/*最后测试节点:
in:
23.234 12.123
-99.99 99.99
-1 -100
正确out:
489.20
实际out:
486.21
*/
2025/1/3 23:59
加载中...