+ 1

Do you guys know what is the problem?

I can't understand why it still have problems maybe it is about "exception" but dont know how to fix it https://code.sololearn.com/c6CooBJ67Ml3/?ref=app

18th Apr 2017, 9:06 AM
양창현
양창현 - avatar
2 Réponses
0
Err... You have too many problems with syntax.
18th Apr 2017, 9:22 AM
Александр Плужников
Александр Плужников - avatar
0
i think this will do :) #include<stdio.h> #include <math.h> #define PI 3.14159265358979 double To_radian(double i) { return i*PI/180; } int main(void) { FILE *fp; int AD=20, Bx=40, By=0, Cx=40, Cy=10, DE=5, PE=10; int l1=5, l2=5; double x1, x2, A, B, p1, p2, th1, th2, Vx, Vy, V; double pre_x1, pre_x2, pre_A, pre_B, pre_th1, pre_th2; double Px[361], Py[361]; double pre_Px[361], pre_Py[361]; double temp1, temp2, pre_p1, pre_p2,pre_temp1,pre_temp2; int i=0; fp=fopen("result.txt", "w"); while(1) { //translate theta1,2 th1=To_radian(i); pre_th1=To_radian(i-0.001); th2=To_radian(2*i-45); pre_th1=To_radian(2*(i-0.001)-45); temp1=Bx+l2*cos(th2); pre_temp1=Bx+l2*cos(pre_th2); temp2=By+l2*sin(th2); pre_temp2=By+12*sin(pre_th2); //calculate x2 x2=sqrt(pow(temp1, 2)+pow(temp2, 2))-AD; pre_x2=sqrt(pow(pre_temp1, 2)+pow(pre_temp2, 2))-AD; temp1=temp1/(x2+AD); pre_temp1=pre_temp1/(x2+AD); temp2=temp2/(x2+AD); pre_temp2=pre_temp2/(x2+AD); //calculate p2 p2=atan2(temp2,temp1); A=Cx+l1*cos(th1)-AD*cos(p2); B=Cy+l1*sin(th1)-AD*sin(p2); pre_p2=atan2(pre_temp2,pre_temp1); pre_A=Cx+l1*cos(pre_th1)-AD*cos(pre_p2); pre_B=Cy+l1*sin(pre_th1)-AD*sin(pre_p2); //calculate x1 x1=sqrt(pow(A, 2)+pow(B, 2)-pow(DE, 2)); temp1=(x1*A+DE*B)/(pow(x1, 2)+pow(DE, 2)); temp2=(x1*B-DE*A)/(pow(x1, 2)+pow(DE, 2)); pre_x1=sqrt(pow(A, 2)+pow(B, 2)-pow(DE, 2)); pre_temp1=(x1*A+DE*B)/(pow(x1, 2)+pow(DE, 2)); pre_temp2=(x1*B-DE*A)/(pow(x1, 2)+pow(DE, 2)); //calculate p1 p1=atan2(temp2,temp1); pre_p1=atan2(pre_temp2,pre_temp1); //calculate Px, Py Px[i]=AD*cos(p2)-DE*sin(p1)-PE*cos(p1); Py[i]=AD*sin(p2)+DE*cos(p1)-PE*sin(p1); pre_Px[i]=AD*cos(pre_p2)-DE*sin(pre_p1)-PE*cos(pre_p1); pre_Py[i]=AD*sin(pre_p2)+DE
18th Apr 2017, 10:27 AM
Nilesh
Nilesh - avatar