huangdicheng @ 2020-12-01 19:35:18
#include<bits/stdc++.h>
using namespace std;
double dis (double x1,double y1,double x2,double y2){
double c;
c=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
return c;
}
int main() {
double x1,y1,x2,y2,x3,y3,a;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
a=dis(x1,x2,y1,y2)+dis(x1,x3,y1,y3)+dis(x2,x3,y2,y3);
printf("%.2lf\n",a);
return 0;
}
by 无秒 @ 2020-12-01 19:38:16
这dis函数很明显调用错了丫……
by _caiji_ @ 2020-12-01 19:39:05
x2-x1可能会出负数,需要求绝对值
by 无秒 @ 2020-12-01 19:40:03
@caijianhong 一乘不就变成正的吗,这无关紧要啊
by kniFe_ @ 2020-12-01 19:42:31
检查一下自定义函数形参列表的顺序吧
by Blood_red @ 2021-01-14 21:17:01
#include <bits/stdc++.h>//万能头登场
using namespace std;
int main(){
double x1,y1,x2,y2,x3,y3,a,b,c;//定义x1,y1等
cin>>x1>>y1>>x2>>y2>>x3>>y3;//输入
a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));//第一条边
b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));//第二条边
c=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));//第三条边
printf("%.2f",a+b+c);//输出
return 0;//结尾
}
一个一个敲!!!!!