- 211 名前:デフォルトの名無しさん mailto:sage [2008/08/14(木) 18:13:40 ]
- スレ誘導されてきました
#include <iostream> using namespace std; //2直線の交点を求める関数 double lineIntersect(double *L1Point, double L1Slope, double *L2Point, double L2Slope); int main() { double P1[2] = {4, 10}; double P2[2] = {6, 18}; double S1 = 2/3; double S2 = 1/3; double ans[2] = {0, 0}; *ans = lineIntersect(P1, S1, P2, S2); cout << "交点の座標は" << ans[0] << '/' << ans[1] << "です\n"; return 0; } double lineIntersect(double *L1Point, double L1Slope, double *L2Point, double L2Slope) { double ans[2] = {0, 0}; ans[0] = (L1Slope * L1Point[0] - L2Slope * L2Point[0] + L2Point[1] - L1Point[1]) / (L2Slope - L1Slope); ans[1] = L1Slope * (ans[0] - L1Point[0]) + L1Point[1]; return ans; } 30分位調べたり考えたりしたのですが1つだけエラーが解決しません;; cpp(29) : error C2440: 'return' : 'double [2]' から 'double' に変換できません。
|

|