我正在编写一个计算函数积分的代码,该函数有两个部分,并且分别计算积分。但编译后我得到了3个错误。请帮忙......
#define I = 0.0225; W = 50000; L = 25; Y = 12000; E = 72*pow(10,9);
#include <stdio.h>
typedef double (*DfD) (double);
double g(double);
double h(double);
double g(double x)
return W*x*(x-L/2)-(Y*pow(x,3))/2 //error: expected declaration specifiers before 'return'
double h(double x)
return (Y*pow(x,3))/2
double midpoint_int(DfD f,
double x0, double x1, int n)
{ int i;
double x, dx, sum = 0.0;
dx = (x1-x0)/n;
for (i = 0, x = x0 + dx/2; i < n; i ++, x +=dx)
sum += f(x);
return sum*dx;
}
int main (void){ //error: expected ',', '=', ';' before '{' token
double int1
double int2
double deflcetion ;
int1 = midpoint_int(g, L/2, L, 1000);
int2 = midpoint_int(h, 0, L/2, 1000);
deflection = 1/EI * (int1 - int2);
return 0
} //error: expected '{' at the end of input
答案 0 :(得分:2)
我试图纠正一些错误
#include <stdio.h>
I = 0.0225;
W = 50000;
L = 25;
Y = 12000;
E = 72*pow(10,9);
typedef double (*DfD) (double);
double g(double);
double h(double);
double g(double x){
return W*x*(x-L/2)-(Y*pow(x,3))/2;
}
double h(double x){
return (Y*pow(x,3))/2;
}
double midpoint_int(DfD f, double x0, double x1, int n)
{
int i;
double x, dx, sum = 0.0;
dx = (x1-x0)/n;
for (i = 0, x = x0 + dx/2; i < n; i ++, x +=dx)
sum += f(x);
return sum*dx;
}
int main (void){
double int1;
double int2;
double deflcetion ;
int1 = midpoint_int(g, L/2, L, 1000);
int2 = midpoint_int(h, 0, L/2, 1000);
deflcetion = 1/E*I * (int1 - int2);
return 0;
}