None_g @ 2023-10-12 17:43:02
#include<bits/stdc++.h>
using namespace std;
int a,m,j,h,g;
double x1,y1,x2,y2,x3,y3;
double xy (double x1,double y1,double x2,double y2)
{
return sqrt(pow(abs(x1-x2),2)+pow(abs(y1-y2),2));
}
int main()
{
cin>>x1>>y1;
cin>>x2>>y2;
cin>>x3>>y3;
printf ("%2f", (xy (x1,y1,x2,y2)+xy (x3,y3,x2,y2)+xy (x1,y1,x3,y3)))
return 0;
}
by yty2010 @ 2023-10-12 17:49:43
pringf 没有加分号
不能定义x1,y1(改c++11可以正常编译)
by chenyuchen_1 @ 2023-10-12 17:49:45
#include<bits/stdc++.h>
using namespace std;
int a,m,j,h,g;
double x1,y1,x2,y2,x3,y3;
double xy (double x1,double y1,double x2,double y2)
{
return sqrt(pow(abs(x1-x2),2)+pow(abs(y1-y2),2));
}
int main()
{
cin>>x1>>y1;
cin>>x2>>y2;
cin>>x3>>y3;
printf ("%2f", (xy (x1,y1,x2,y2)+xy (x3,y3,x2,y2)+xy (x1,y1,x3,y3)))//<<少了个分号
return 0;
}
还有,下次这么点问题就别问了,自己调试
by yty2010 @ 2023-10-12 17:50:23
或者改变量名
by chenyuchen_1 @ 2023-10-12 17:54:00
搜寻y1函数 会很慢,请耐心等待
by None_g @ 2023-10-13 22:01:39
@chenyuchen_1改了,终于过样题了
#include<bits/stdc++.h>
using namespace std;
int m,j,h,g;
double x,y,a,b,c,d;
double xy (double x,double y,double z,double a)
{
return sqrt(pow(abs(x-z),2)+pow(abs(y-a),2));
}
int main()
{
cin>>x>>y;
cin>>a>>b;
cin>>c>>d;
printf ("%.2f", (xy (x,y,a,b)+xy (c,d,a,b)+xy (x,y,c,d)));
return 0;
}
中间还有个问题,是 "%.2f"
,而不是"%2f"