社区讨论

求大佬看一下,哪里有问题80分最后一个不对

P5735【深基7.例1】距离函数参与者 2已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@m3xwdor6
此快照首次捕获于
2024/11/26 11:28
去年
此快照最后确认于
2025/11/04 13:54
4 个月前
查看原帖
CPP
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
float dis(int a, int b, int c, int d);
int main() {
	int x1, x2, y1, y2, x3, y3;
	double a,b,c,sum;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	a = dis(x1, y1, x2, y2);
	b = dis(x1, y1, x3, y3);
	c = dis(x2, y2, x3, y3);
	sum=a + b + c;
	cout << fixed << setprecision(2) << sum;
}

float dis(int a, int b,int c,int d) {
	float distant;
	distant = sqrt((a - c) * (a - c) + (b - d) * (b - d));
		return distant;
}

回复

1 条回复,欢迎继续交流。

正在加载回复...