Advertisement
cosenza987

asdasd

Mar 27th, 2021
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. const double pi = 3.1415;
  5. const double g = 9.8;
  6.  
  7. int main() {
  8.     double xa, ya, v0, a, b, c, delta, theta1 = 0, theta2 = 0, ang1 = 0, ang2 = 0, t1 = 0, t2 = 0, ind = 0; // essa porra eh igual funcao quadratica
  9.     scanf("%lf %lf %lf", &xa, &ya, &v0);
  10.     a = ((g*(xa*xa))/(2*(v0*v0)));
  11.     b = xa * -1;
  12.     c = a + ya;
  13.     delta = (b*b) - (4*a*c);
  14.     if(delta >= 0) {
  15.         theta1 = ((b*(-1)) + sqrt(delta)) / (2*a);
  16.         theta2 = ((b*(-1)) - sqrt(delta)) / (2*a);
  17.         ang1 = atan(theta1);
  18.         ang2 = atan(theta2);
  19.         t1 = (xa/v0) * sin(ang1);
  20.         t2 = (xa/v0) * sin(ang2);
  21.         ind++;
  22.     }
  23.     double grau1, min1, sec1, grau2, min2, sec2, temp;
  24.     if(ind != 0) {
  25.         grau1 = (ang1*180) / pi;
  26.         temp = grau1 - floor(grau1);
  27.         grau1 = floor(grau1);
  28.         min1 = temp*60;
  29.         temp = min1 - floor(min1);
  30.         min1 = floor(min1);
  31.         sec1 = temp*60;
  32.         sec1 = floor(sec1);
  33.         grau2 = (ang2*180) / pi;
  34.         temp = grau2 - floor(grau2);
  35.         grau2 = floor(grau2);
  36.         min2 = temp*60;
  37.         temp = min2 - floor(min2);
  38.         min2 = floor(min2);
  39.         sec2 = temp*60;
  40.         sec2 = floor(sec2);
  41.         printf("%.0lf %.0lf %.0lf, tempo = %.4lf\n", grau1, min1, sec1, t1);
  42.         printf("%.0lf %.0lf %.0lf, tempo = %.4lf\n", grau2, min2, sec2, t2);
  43.     } else {
  44.         printf("deu ruim lol\n");
  45.     }
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement