编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#47427 #1138. ddd和鹦鹉 Compile Error 0 0 ms 0 K C++ / 738 B 喵喵 2021-04-04 20:44:14
显示原始代码
#include <iostream>
#include <algorithm>
using namespace std;
const double inf = 99999999999.0;
double cal(int x1, int y1, int x2, int y2) {
    double val;
    val = 1.0 * sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int main() {
    int ax, ay, bx, by, cx, cy;
    double dis = inf;
    int ox, oy;
    cin >> ax >> ay >> bx >> by >> cx >> cy;
    int minx, miny, maxx, maxy;
    minx = min(min(ax, bx), cx);
    maxx = max(max(ax, bx), cx);
    miny = min(min(ay, by), cy);
    maxy = max(max(ay, by), cy);
    for (int i = minx; i <= maxx; i++) {
        for (int j = miny; j <= maxy; j++) {
            double ndis = 3.0 * cal(i, j, ax, ay) + 2.0 * cal(i, j, bx, by) + 1.0 * cal(i, j, cx, cy);
            //			cout<<i<<" "<<j<<endl;
            if (ndis < dis) {
                dis = ndis;
                ox = i, oy = j;
            }
        }
    }
    //	cout<<minx;
    cout << ox << " " << oy;
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'double cal(int, int, int, int)':
/sandbox/1/a.cpp:8:10: error: 'sqrt' was not declared in this scope
  val=1.0*sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
          ^~~~
/sandbox/1/a.cpp:8:10: note: suggested alternative: 'qsort'
  val=1.0*sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
          ^~~~
          qsort
/sandbox/1/a.cpp:9:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^