1 #include
2 #include
3 #include
4 #include
5 const double G=1; //万有引力常量
6 double m; //三个质点的同一质量
7 double initial[20],result[20]; //迭代数组
8 double a,b,h; //区间和步长
9 double step; //分段数
10 using namespacestd;11
12 //以下六个函数对应六个位移对时间求导的微分方程
13 double fx1(double t,double x1,double y1,double x2,double y2,double x3,double y3,double vx1,double vy1,double vx2,double vy2,double vx3,doublevy3)14 {15 doubledx1;16 dx1=vx1;17 returndx1;18 }19 double gy1(double t,double x1,double y1,double x2,double y2,double x3,double y3,double vx1,double vy1,double vx2,double vy2,double vx3,doublevy3)20 {21 doubledy1;22 dy1=vy1;23 returndy1;24 }25 double fx2(double t,double x1,double y1,double x2,double y2,double x3,double y3,double vx1,double vy1,double vx2,double vy2,double vx3,doublevy3)26 {27 doubledx2;28 dx2=vx2;29 returndx2;30 }31 double gy2(double t,double x1,dou