Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- const double pi = 3.1415;
- const double g = 9.8;
- int main() {
- 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
- scanf("%lf %lf %lf", &xa, &ya, &v0);
- a = ((g*(xa*xa))/(2*(v0*v0)));
- b = xa * -1;
- c = a + ya;
- delta = (b*b) - (4*a*c);
- if(delta >= 0) {
- theta1 = ((b*(-1)) + sqrt(delta)) / (2*a);
- theta2 = ((b*(-1)) - sqrt(delta)) / (2*a);
- ang1 = atan(theta1);
- ang2 = atan(theta2);
- t1 = (xa/v0) * sin(ang1);
- t2 = (xa/v0) * sin(ang2);
- ind++;
- }
- double grau1, min1, sec1, grau2, min2, sec2, temp;
- if(ind != 0) {
- grau1 = (ang1*180) / pi;
- temp = grau1 - floor(grau1);
- grau1 = floor(grau1);
- min1 = temp*60;
- temp = min1 - floor(min1);
- min1 = floor(min1);
- sec1 = temp*60;
- sec1 = floor(sec1);
- grau2 = (ang2*180) / pi;
- temp = grau2 - floor(grau2);
- grau2 = floor(grau2);
- min2 = temp*60;
- temp = min2 - floor(min2);
- min2 = floor(min2);
- sec2 = temp*60;
- sec2 = floor(sec2);
- printf("%.0lf %.0lf %.0lf, tempo = %.4lf\n", grau1, min1, sec1, t1);
- printf("%.0lf %.0lf %.0lf, tempo = %.4lf\n", grau2, min2, sec2, t2);
- } else {
- printf("deu ruim lol\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement