fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4.  
  5. int main() {
  6.  
  7. int n,i,j=0;
  8. double Vx,Vy,g,x[1024],y[1024],X,Y,a,b,c,t;
  9.  
  10. cin >> g;
  11. cin >> Vx;
  12. cin >> Vy;
  13.  
  14. cin >> n;
  15.  
  16. for(i=0;i<n,i++) {
  17. cin >> x[i];
  18. cin >> y[i];
  19. }
  20.  
  21. for(i=0;i<n-1;i++) {
  22.  
  23. a=g/(2*Vx*Vx);
  24. b=(y[i+1]-y[i])/(xi+1]x[i])-Vy/Vx;
  25. c=y[i]-(y[i+1]-y[i])/(x[i+1]-x[i])*x[i];
  26.  
  27. X=(-b+sqrt(b*b-4*a*c))/(2*a);
  28. Y=(y[i+1]-y[i])/(xi+1]x[i])*(X-x[i])+y[i];
  29. t=X/Vx;
  30.  
  31. if((((X>=x[i])&&(X<x[i+1]))||((X<=x[i])&&(X>x[i+1])))&&(((Y>=y[i])&&(Y<y[i+1]))||((Y<=y[i])&&(Y>y[i+1])) ) {
  32. cout <<"1";
  33. cout << X << " " << Y << " " << t << " " << i <<endl;
  34. j=1;
  35. i=n;
  36. }
  37. }
  38.  
  39. if(j=0) cout << "0" <<endl;
  40.  
  41. return 0;
  42. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:10:2: error: ‘cin’ undeclared (first use in this function)
  cin >> g;
  ^~~
prog.c:10:2: note: each undeclared identifier is reported only once for each function it appears in
prog.c:16:13: warning: left-hand operand of comma expression has no effect [-Wunused-value]
  for(i=0;i<n,i++) {
             ^
prog.c:16:17: error: expected ‘;’ before ‘)’ token
  for(i=0;i<n,i++) {
                 ^
prog.c:24:19: error: ‘xi’ undeclared (first use in this function)
  b=(y[i+1]-y[i])/(xi+1]x[i])-Vy/Vx;
                   ^~
prog.c:24:23: error: expected ‘)’ before ‘]’ token
  b=(y[i+1]-y[i])/(xi+1]x[i])-Vy/Vx;
                       ^
prog.c:24:23: error: expected ‘;’ before ‘]’ token
prog.c:24:23: error: expected statement before ‘]’ token
prog.c:24:25: warning: statement with no effect [-Wunused-value]
  b=(y[i+1]-y[i])/(xi+1]x[i])-Vy/Vx;
                        ~^~~
prog.c:24:28: error: expected ‘;’ before ‘)’ token
  b=(y[i+1]-y[i])/(xi+1]x[i])-Vy/Vx;
                            ^
prog.c:24:28: error: expected statement before ‘)’ token
prog.c:24:32: warning: statement with no effect [-Wunused-value]
  b=(y[i+1]-y[i])/(xi+1]x[i])-Vy/Vx;
                             ~~~^~~
prog.c:28:23: error: expected ‘)’ before ‘]’ token
  Y=(y[i+1]-y[i])/(xi+1]x[i])*(X-x[i])+y[i];
                       ^
prog.c:28:23: error: expected ‘;’ before ‘]’ token
prog.c:28:23: error: expected statement before ‘]’ token
prog.c:28:25: warning: statement with no effect [-Wunused-value]
  Y=(y[i+1]-y[i])/(xi+1]x[i])*(X-x[i])+y[i];
                        ~^~~
prog.c:28:28: error: expected ‘;’ before ‘)’ token
  Y=(y[i+1]-y[i])/(xi+1]x[i])*(X-x[i])+y[i];
                            ^
prog.c:28:28: error: expected statement before ‘)’ token
prog.c:28:29: error: invalid type argument of unary ‘*’ (have ‘double’)
  Y=(y[i+1]-y[i])/(xi+1]x[i])*(X-x[i])+y[i];
                             ^~~~~~~~~
prog.c:31:109: error: expected ‘)’ before ‘{’ token
  if((((X>=x[i])&&(X<x[i+1]))||((X<=x[i])&&(X>x[i+1])))&&(((Y>=y[i])&&(Y<y[i+1]))||((Y<=y[i])&&(Y>y[i+1])) ) {
                                                                                                             ^
prog.c:37:2: error: expected expression before ‘}’ token
  }
  ^
prog.c:39:2: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  if(j=0) cout << "0" <<endl;
  ^~
prog.c:39:10: error: ‘cout’ undeclared (first use in this function)
  if(j=0) cout << "0" <<endl;
          ^~~~
prog.c:39:24: error: ‘endl’ undeclared (first use in this function)
  if(j=0) cout << "0" <<endl;
                        ^~~~
prog.c:8:43: warning: variable ‘t’ set but not used [-Wunused-but-set-variable]
  double Vx,Vy,g,x[1024],y[1024],X,Y,a,b,c,t;
                                           ^
stdout
Standard output is empty