为什么我的C语言程序输出不出来 20
#include<stdio.h>#include<math.h>intmain(){//yourcodeheretoimplementProject4doublev;d...
#include <stdio.h>
#include <math.h>
int main() {
// your code here to implement Project 4
double v;
double t = 0.00001;
double artLength;
double c;
double a;
printf("vo(m/s): ");
scanf("%lf",&v);
printf("C_d (1/m): ");
scanf("%lf",&c);
printf("artLength (m): ");
scanf("%lf",&artLength);
double fmax = pow(v,2)/(2*artLength);
double fmin = 0;
double x = 0;
double fmid;
while(fmax-fmin>=0.000001){
while(x>0){
fmid = 0.5*(fmax+fmin);
a = -fmid-c*pow(v,2);
x = x + v*t;
v = v + a*t;
}
return x;
if(x<artLength){
fmax = fmid;
}
else{
fmin = fmid;
}
}
printf("f_optimal = %lf",fmid);
} 展开
#include <math.h>
int main() {
// your code here to implement Project 4
double v;
double t = 0.00001;
double artLength;
double c;
double a;
printf("vo(m/s): ");
scanf("%lf",&v);
printf("C_d (1/m): ");
scanf("%lf",&c);
printf("artLength (m): ");
scanf("%lf",&artLength);
double fmax = pow(v,2)/(2*artLength);
double fmin = 0;
double x = 0;
double fmid;
while(fmax-fmin>=0.000001){
while(x>0){
fmid = 0.5*(fmax+fmin);
a = -fmid-c*pow(v,2);
x = x + v*t;
v = v + a*t;
}
return x;
if(x<artLength){
fmax = fmid;
}
else{
fmin = fmid;
}
}
printf("f_optimal = %lf",fmid);
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询