想不清楚为什么,请大佬帮忙!

P5735 【深基7.例1】距离函数

QHWLL @ 2020-06-14 08:34:07

我用 《iostream》 过了,用《cstdio》测试点5没过,想不清楚为什么,请大佬帮忙!```cpp

include <iostream>

include <cmath>

include <iomanip>

using namespace std; double dis(double x1,double x2,double y1,double y2) { double ans; ans=sqrt(pow((x2-x1),2)+pow((y2-y1),2)); return ans; } int main() { double x1,x2,x3,y1,y2,y3; double answer; cin>>x1>>y1>>x2>>y2>>x3>>y3; answer=dis(x1,x2,y1,y2)+dis(x1,x3,y1,y3)+dis(x2,x3,y2,y3); cout<<fixed<<setprecision(2)<<answer; return 0; }

```cpp
#include <cstdio>
#include <cmath>
using namespace std;
double dis(double x1,double x2,double y1,double y2)
{
    double ans;
    ans=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
    return ans;
}
int main()
{
    double x1,x2,x3,y1,y2,y3;
    double answer;
    scanf("%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
    answer=dis(x1,x2,y1,y2)+dis(x1,x3,y1,y3)+dis(x2,x3,y2,y3);
    printf("%.2lf",answer);
    return 0;
}

by QHWLL @ 2020-06-14 08:35:15

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
double dis(double x1,double x2,double y1,double y2)
{
    double ans;
    ans=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
    return ans;
}
int main()
{
    double x1,x2,x3,y1,y2,y3;
    double answer;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    answer=dis(x1,x2,y1,y2)+dis(x1,x3,y1,y3)+dis(x2,x3,y2,y3);
    cout<<fixed<<setprecision(2)<<answer;
    return 0;
}

这个补充,上面没发出来

谢谢


by Smile_Cindy @ 2020-06-14 08:39:30

@QHWLL

scanf("%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);

请仔细阅读您的代码。


by novax @ 2020-06-14 08:39:48

谔谔,


by 莜沐YouMu @ 2020-06-14 08:41:32

非常明显 scanf写错了


by WanderingTrader @ 2020-06-14 08:45:11

IEE


by Diamiko @ 2020-06-14 08:54:33

@QHWLL 输入六个数只打3个占位符我谔谔


by wangyilin @ 2020-06-14 08:56:48

非常明显 scanf写错了


by QHWLL @ 2020-06-14 09:11:12

默默的走开。。。


by TimmyL @ 2020-06-14 09:11:27

我谔谔


by PragmaGCC @ 2020-06-14 09:50:04

scanf骇死我了


|