Bubbles2023 @ 2024-05-24 16:54:26
C++,样例过了,20分
点击查看 评测记录
数据点 | 评测结果 |
---|---|
#1 | 正确 AC |
#2 | 错误 WA |
#3 | 错误 WA |
#4 | 错误 WA |
#5 | 错误 WA |
附错误代码 1份
#include<bits/stdc++.h>
using namespace std;
int x,y,x2,y2,x3,y3;
double dis(int a,int b,int c,int d)
{
a=abs(a),b=abs(b),c=abs(c),d=abs(d);
return abs(sqrt(((c-a)*(c-a))+((d-b)*(d-b))));
}
int main(){
cin>>x>>y>>x2>>y2>>x3>>y3;
printf("%.2f",dis(x,y,x2,y2)+dis(x,y,x3,y3)+dis(x2,y2,x3,y3));
return 0;
}
Thanks♪(・ω・)ノ
by weak_in_code @ 2024-05-24 16:55:14
@Bubbles2023 坐标均为实数
by Stars_visitor_tyw @ 2024-05-24 16:58:26
@Bubbles2023
#include<bits/stdc++.h>
using namespace std;
int main()
{
double x1,y1,x2,y2,x3,y3,dis1,dis2,dis3,ans=0;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
dis1=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
dis2=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
dis3=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
ans=dis1+dis2+dis3;
cout<<fixed<<setprecision(2)<<ans;
return 0;
}
by weak_in_code @ 2024-05-24 16:59:30
@Bubbles2023 为啥 abs 啊,直接算吧。
还有,输入可能为小数。
#include<bits/stdc++.h>
using namespace std;
double x,y,x2,y2,x3,y3;
double dis(double a,double b,double c,double d)
{
return abs(sqrt(((c-a)*(c-a))+((d-b)*(d-b))));
}
int main(){
cin>>x>>y>>x2>>y2>>x3>>y3;
printf("%.2lf",dis(x,y,x2,y2)+dis(x,y,x3,y3)+dis(x2,y2,x3,y3));
return 0;
}
by Bubbles2023 @ 2024-05-24 17:18:27
@weak_in_code @taoyiwei17_cfynry 谢谢二位!
by yoyowcx @ 2024-06-05 23:18:59
int x,y,x2,y2,x3,y3; 错了