C++80分代码,测5有误,求找茬

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

玖沂 @ 2020-12-19 20:40:29

代码如下:

#include<bits/stdc++.h>
using namespace std;
double dis(double x1,double y1,double x2,double y2){
    return sqrt(pow((x1-x2),2)+pow((y1-y2),2));
}
int main(){
    int x1,y1,x2,y2,x3,y3;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    double d1=dis(x1,y1,x2,y2);
    double d2=dis(x2,y2,x3,y3);
    double d3=dis(x1,y1,x3,y3);
    double c=d1+d2+d3;
    cout << fixed << setprecision(2) << c;
    return 0;
}

by 玖沂 @ 2020-12-19 20:43:48

咳咳,自己找出来了,尴尬尴尬,第7行int改为double


by Blood_red @ 2021-01-14 21:07:48

    int x1,y1,x2,y2,x3,y3;

int!!过过脑子!


|