Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
997 yy026 最近距离 C++ 编译错误 0 MS 0 KB 1299 2022-05-28 10:13:27

Tests(0/0):


#include <iostream> #include <cmath> #include <string> using namespace std; struct obstacle { string carname; float x, y; float distance; obstacle *next; } obstacle *head = nullptr; float DistanceToOrigin (float x, float y) { float distance; distance = sqrt((x*x) + (y*y)); return distance; } float CalcNearestPoint(obstacle points[], obstacle point, int n) { obstacle temp; for (int i=0;i<n;i++){ if(points[i].distance>points[i-1].distance) { temp.distance = points[i].distance; points[i].distance = points[i-1].distance ; points[i-1].distance = temp.distance; } } DistanceToOrigin(points[0].x,points[0].y); } void insertObstacle (string name, float a, float b) { obstacle *newObstacle = new obstacle; newObstacle->carname = name; newObstacle->x = a; newObstacle->y = b; newObstacle->next = head; head = newObstacle; } int main() { int x, y; string name; while (name != "0"){ { cout << "string describing obstacle (""0"" for end of input):"; cin >>name; cout << "\nx and y coordinate: "; cin >> x >> y; insertObstacle(name, x, y); } } }


测评信息: