求助自己在VS测试了很多遍数据没问题但是这一直报五个WA

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

lwj12138 @ 2021-12-01 21:43:50

实在是不知道错哪了,自己验证数据没有问题但是一直五个WA

#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;

//求A边长
double distanceA(double x1, double y1, double x2, double y2)
{
    double A = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
    return A;
}

//求B边长
double distanceB(double x1, double y1, double x3, double y3)
{
    double B = sqrt((x3 - x1)*(x3 - x1) + (y3 - y1)*(y3 - y1));
    return B;
}

//求C边长
double distanceC(double x2, double y2, double x3, double y3)
{
    double C = sqrt((x3 - x2)*(x3 - x2) + (y3 - y2)*(y3 - y2));
    return C;
}
//主调函数,存储所有数据
int main()
{
    double x1, y1, x2, y2, x3, y3;
    cout << "请输入A点坐标(x1,y1)" << endl;
    cin >> x1 >> y1;
    cout << "请输入B点坐标(x2,y2)" << endl;
    cin >> x2 >> y2;
    cout << "请输入X点坐标(x3,y3)" << endl;
    cin >> x3 >> y3;

   //求周长(用绝对值控制每个值)
    cout << "三边长和为: " << setiosflags(ios::fixed)<<setprecision(2)<<distanceA(abs(x1), abs(y1), abs(x2), abs(y2))+ distanceB(abs(x1), abs(y1), abs(x3), abs(y3))+ distanceC(abs(x2), abs(y2), abs(x3), abs(y3)) << endl;

        system("pause");
        return 0;
}

by 昒昕 @ 2021-12-01 21:45:15

@lwj12138 不要输出提示信息


by StillEmpty @ 2021-12-01 21:49:10

绝了


by _QrSn_ @ 2021-12-01 22:03:31

请问能不能笑


by lwj12138 @ 2021-12-02 21:49:44

@强人锁男 可以,我太菜了QAQ


by EC75 @ 2021-12-05 19:35:15

@lwj12138

cout << "请输入A点坐标(x1,y1)" << endl;
    cin >> x1 >> y1;
    cout << "请输入B点坐标(x2,y2)" << endl;
    cin >> x2 >> y2;
    cout << "请输入X点坐标(x3,y3)" << endl;
    cin >> x3 >> y3;

???您老人家是来搞笑的嘛?

请看P1001里的要求!!!


|