求助,各路大大看看有什么错误

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

大宇治水 @ 2020-09-06 16:02:13

感到了深深的绝望跪求为啥

#include<bits/stdc++.h>
using namespace std;
double h(double a,double b,double c,double d,double s){
    s=sqrt((a-b)*(a-b)+(c-d)*(c-d));
    return s;
}

int main(){
        double s=0,s1,s2,s3,x1,x2,x3,y1,y2,y3;
    cin>>x1>>x2>>x3>>y1>>y2>>y3;
    s=(h(s1,x2,x1,y2,y1)+h(s2,x1,x3,y1,y3)+h(s3,x2,x3,y2,y3))%.2;
    cout<<s;
    return 0;
}

运行后还少1


by 江户川·萝卜 @ 2020-09-06 16:05:18

怕是printf学傻了

%.2


by 大宇治水 @ 2020-09-06 16:16:12

@江户川·萝卜 删了还是少一╮(╯▽╰)╭


by 江户川·萝卜 @ 2020-09-06 16:20:21

@大宇治水 s位置放错了


by 大宇治水 @ 2020-09-06 16:22:31

@江户川·萝卜 谢谢


|