我的样例都不对,我太菜了...

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

MilkyCoffee @ 2020-04-24 11:30:46

哈罗,我又又又又又是那个牛奶小咖啡(以后不打又了)

我的开场白不一样了!!!(奇闻):就算我的程序里有注释,我的代码还是可读性极差~

// #include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;

int s(int a, int b, int c, int d) {
    return sqrt(abs(a - b) * abs(a - b) + abs(c - d) * abs(c - d));
}

int main() {
    int x[5], y[5];
    cin >> x[1] >> x[2] >> x[3];
    cin >> y[1] >> y[2] >> y[3];
    double ans = 0;
    ans += s(x[1], x[2], y[1], y[2]);
    ans += s(x[2], x[3], y[2], y[3]);
    ans += s(x[3], x[1], y[3], y[1]);
    cout << fixed << setprecision(2) << ans << endl;
    return 0;
}

by Adhara @ 2020-04-24 11:31:36

为什么返回值是int啊


by FZzzz @ 2020-04-24 11:31:42

@牛奶小咖啡 你这 s 显然不能开 int


by MilkyCoffee @ 2020-04-24 11:32:15

蟹蟹!~


by MilkyCoffee @ 2020-04-24 11:32:36

还是不对啊@FZzzz


by MilkyCoffee @ 2020-04-24 11:32:46

@Adhara


by Fatalis_Lights @ 2020-04-24 11:33:28

坐标值是实数


by Adhara @ 2020-04-24 11:34:09

坐标值是实数


by FZzzz @ 2020-04-24 11:34:32

@牛奶小咖啡 输入也没说就是整数吧


by MilkyCoffee @ 2020-04-24 11:36:39

都改了


by MilkyCoffee @ 2020-04-24 11:36:53

但是还是不对啊!!!


| 下一页