c++求助

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

Etic_HAO @ 2022-07-21 19:21:31

5个WA??????????????????????????????????????????????

#include <bits/stdc++.h>
using namespace std;

int main(){
      double x1,y1,x2,y2,x3,y3,a,b,c;
      cin>>x1>>y1>>x2>>y2>>x3>>y3;
      a=sqrt(pow(x2-x1,2)*pow(y2-y1,2));
      b=sqrt(pow(x3-x2,2)*pow(y3-y2,2));
      c=sqrt(pow(x1-x3,2)*pow(y1-y3,2));
      cout<<fixed<<setprecision(2);      
      cout<<a+b+c;
} 

嘤嘤嘤(;´༎ຶД༎ຶ`)


by 032o35 @ 2022-07-21 19:29:09

pow函数有精度差,建议手写平方


by CreutzWilknare @ 2022-07-21 19:29:12

公式输错了


by CreutzWilknare @ 2022-07-21 19:29:27

题目写加法你写仨乘


by CreutzWilknare @ 2022-07-21 19:30:02

@032o35 你自己试了吗?


by 032o35 @ 2022-07-21 19:31:16

@Weirdle 抱歉,我是把我手写平方贴上来了,以为就是这个错


by AAA404 @ 2022-07-21 19:34:49

sqrt(pow(x1-x2,2)+pow(y1-y2)) 其他也这样改


by Etic_HAO @ 2022-07-21 20:08:45

@Weirdle

O(∩_∩)O谢谢


by Etic_HAO @ 2022-07-21 20:09:19

@AAA404

O(∩_∩)O谢谢


by Etic_HAO @ 2022-07-21 20:12:00

世上竟有如此巧合之事!!!

Σ(っ °Д °;)っΣ(っ °Д °;)っΣ(っ °Д °;)っ

我样例过了

嘻嘻嘻嘻嘻嘻(●'◡'●)


|