XiaoJuRuoUP @ 2020-10-24 20:24:10
代码如下:
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double discover(double x1,double x2,double y1,double y2){
double dis;
dis=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
return dis;
}
int main(){
double a1,b1,a2,b2,a3,b3,sum=0;
cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
sum+=discover(a1,a2,b1,b2);
sum+=discover(a1,a3,b1,b3);
sum+=discover(a2,a3,b2,b3);
printf("%2lf",sum);
return 0;
}
J某百思不得其解,只好求助各位神犇。在此感激不尽
by EgLund @ 2020-10-24 20:28:53
"%.2lf"
by LucasXu80 @ 2020-10-24 20:28:56
printf("%2lf",sum);
这句好像不对?
by Zlylovecoding @ 2020-10-24 20:34:06
最后的printf输出写错了。 漏了个小数点
保留小数点后两位应该写:
printf("%.2lf",sum);
by XiaoJuRuoUP @ 2020-10-25 10:48:21
感谢各位大佬,现在全绿了。