代码框架
上一节
下一节
#include<stdio.h>
#include<math.h>
double g=9.8, mk, v0, gmk;
//定义公式(8)中的f(x)=0
double f(double theta){
return .....;
}
//solve f(x)=0 by bi-section method
double solve_f_bisection(double xl, double xh, double err) {
......
return ...;
}
// or solve f(x)=0 by iteration method
double solve_f_iteration(double x0 , double err) {
......
return ...;
}
int main(){
printf("input mk, v0 :");
scanf("%lf%lf",&mk,&v0);
gmk = g*mk;
double theta = solve_f_bisection(....);
// 或者 double theta = solve_f_iteration(.....);
//打印输出theta, 及最大射程
return 0;
}