プログラムをある程度はつくりましたが
コンパイルエラーが出てしまいます
よければ原因などよろしくお願いします
#include<stdio.h>
#include<math.h>
int Fx(double x1,x2,y1,y2,l){
double l0,Dl,fx;
l0 = sqrt((x2-x1)^2+(y2-y1)^2);
Dl = l0 - l;//変位
fx = (-Dl*(x1-x2)/l0);
return(fx);
}
int Fy(double x1,y1,x2,y2,l){
double l0,Dl,fy;
l0 = sqrt((x2-x1)^2+(y2-y1)^2);
Dl = l0 - l;//変位
fy = (-Dl*(y1-y2)/l0);
return(fy);
}
int main(void){
double l10,l20,l30,fx1,fx2,fx3,fy1,fy2,fy3;
l10 = 10.0;
l20 = 11.18033989;
l30 = 11.18033989;
double Dt,t,vx1,vy1,vx2,vy2,vx3,vy3;
Dt = 0.0001;
int i;
x1 = 0.01;
y1 = 0.00;
x2 = 0.00;
y2 = 10.00;
x3 = 10.00;
y3 = 5.00;
vx1 = 0.0;
vy1 = 0.0;
vx2 = 0.0;
vy2 = 0.0;
vx3 = 0.0;
vy3 = 0.0;
fx1 = Fx(x1,x2,y1,y2,l10)+Fx(x3,x1,y3,y1,l30);
fy1 = Fy(x1,x2,y1,y2,l10)+Fy(x3,x1,y3,y1,l30);
fx2 = Fx(x2,x1,y2,y1,l10)+Fx(x3,x2,y3,y2,l20);
fy2 = Fy(x2,x1,y2,y1,l10)+Fy(x3,x2,y3,y2,l20);
fx3 = Fx(x1,x3,y1,y3,l30)+Fx(x2,x3,y2,y3,l20);
fy3 = Fy(x1,x3,y1,y3,l30)+Fy(x2,x3,y2,y3,l20);
for(i=0;i<100;i++){
vx1 = vx1+fx1*Dt;
vy1 = vy1+fy1*Dt;
vx2 = vx2+fx2*Dt;
vy2 = vy2+fy2*Dt;
vx3 = vx3+fx3*Dt;
vy3 = vx3+fy3*Dt;
x1 = x1+vx1*Dt;
y1 = y1+vy1*Dt;
x2 = x2+vx2*Dt;
y2 = y2+vy2*Dt;
x3 = x3+vx3*Dt;
y3 = x3+vy3*Dt;
printf("x1=%lf y1=%lf x2=%lf y2=%lf x3=%lf y3=%lf \n",x1,y1,x2,y2,x3,y3);
fx1 = Fx(x1,x2,y1,y2,l10)+Fx(x3,x1,y3,y1,l30);
fy1 = Fy(x1,x2,y1,y2,l10)+Fy(x3,x1,y3,y1,l30);
fx2 = Fx(x2,x1,y2,y1,l10)+Fx(x3,x2,y3,y2,l20);
fy2 = Fy(x2,x1,y2,y1,l10)+Fy(x3,x2,y3,y2,l20);
fx3 = Fx(x1,x3,y1,y3,l30)+Fx(x2,x3,y2,y3,l20);
fy3 = Fy(x1,x3,y1,y3,l30)+Fy(x2,x3,y2,y3,l20);
}
return;
}
で、出るコンパイルエラーが
pbl-A.c:4: error: expected declaration specifiers or ‘...’ before ‘y1’
pbl-A.c:4: error: expected declaration specifiers or ‘...’ before ‘y2’
pbl-A.c:4: error: expected declaration specifiers or ‘...’ before ‘l’
pbl-A.c: In function ‘Fx’:
pbl-A.c:7: error: ‘x2’ undeclared (first use in this function)
pbl-A.c:7: error: (Each undeclared identifier is reported only once
pbl-A.c:7: error: for each function it appears in.)
pbl-A.c:7: error: ‘y2’ undeclared (first use in this function)
pbl-A.c:9: error: ‘l’ undeclared (first use in this function)
pbl-A.c: At top level:
pbl-A.c:15: error: expected declaration specifiers or ‘...’ before ‘y1’
pbl-A.c:15: error: expected declaration specifiers or ‘...’ before ‘x2’
pbl-A.c:15: error: expected declaration specifiers or ‘...’ before ‘y2’
pbl-A.c:15: error: expected declaration specifiers or ‘...’ before ‘l’
pbl-A.c: In function ‘Fy’:
pbl-A.c:18: error: ‘x2’ undeclared (first use in this function)
pbl-A.c:18: error: ‘y2’ undeclared (first use in this function)
pbl-A.c:20: error: ‘l’ undeclared (first use in this function)
pbl-A.c: In function ‘main’:
pbl-A.c:38: error: ‘x1’ undeclared (first use in this function)
pbl-A.c:39: error: lvalue required as left operand of assignment
pbl-A.c:40: error: ‘x2’ undeclared (first use in this function)
pbl-A.c:41: error: ‘y2’ undeclared (first use in this function)
pbl-A.c:42: error: ‘x3’ undeclared (first use in this function)
pbl-A.c:43: error: ‘y3’ undeclared (first use in this function)
pbl-A.c:52: error: too many arguments to function ‘Fx’
pbl-A.c:52: error: too many arguments to function ‘Fx’
pbl-A.c:53: error: too many arguments to function ‘Fy’
pbl-A.c:53: error: too many arguments to function ‘Fy’
pbl-A.c:54: error: too many arguments to function ‘Fx’
pbl-A.c:54: error: too many arguments to function ‘Fx’
pbl-A.c:55: error: too many arguments to function ‘Fy’
pbl-A.c:55: error: too many arguments to function ‘Fy’
pbl-A.c:56: error: too many arguments to function ‘Fx’
pbl-A.c:56: error: too many arguments to function ‘Fx’
pbl-A.c:57: error: too many arguments to function ‘Fy’
pbl-A.c:57: error: too many arguments to function ‘Fy’
pbl-A.c:73: error: invalid operands to binary + (have ‘double (*)(double)’ and ‘ double’)
pbl-A.c:81: error: too many arguments to function ‘Fx’
pbl-A.c:81: error: too many arguments to function ‘Fx’
pbl-A.c:82: error: too many arguments to function ‘Fy’
pbl-A.c:82: error: too many arguments to function ‘Fy’
pbl-A.c:83: error: too many arguments to function ‘Fx’
pbl-A.c:83: error: too many arguments to function ‘Fx’
pbl-A.c:84: error: too many arguments to function ‘Fy’
pbl-A.c:84: error: too many arguments to function ‘Fy’
pbl-A.c:85: error: too many arguments to function ‘Fx’
pbl-A.c:85: error: too many arguments to function ‘Fx’
pbl-A.c:86: error: too many arguments to function ‘Fy’
pbl-A.c:86: error: too many arguments to function ‘Fy’
本当に困っています
よろしくお願いします