Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<math.h>
  4. #define G_CONST 9.81
  5. //---------------------------------------------------------------------
  6. float Height(float deg, float time, float V)
  7. {
  8. float Vy;
  9. deg = (deg *3.14)/180;
  10. Vy = V*sin(deg);
  11. float height = Vy*time - G_CONST*(time*time) / 2;
  12. return height;
  13. }
  14. //---------------------------------------------------------------------
  15. float horizontal(float deg, float time, float V)
  16. {
  17. float Vx;
  18. deg = (deg *3.14) / 180;
  19. Vx = V*cos(deg);
  20. float S = Vx*time;
  21. return S;
  22. }
  23. //---------------------------------------------------------------------
  24. int main()
  25. {
  26. int i = 1;
  27. while (1)
  28. {
  29. float V;
  30. int deg;
  31. float height = 0.0;
  32. float distance = 0.0;
  33. float time = 0.1;
  34. printf("Enter v (0.0-100.0 m/s and a (0-90) degress): ");
  35. scanf("%f %d", &V, &deg);
  36. if (deg > 90 || deg < 0)
  37. {
  38. printf("\n wrong angle!");
  39. }
  40. if (V > 100 || V < 0)
  41. {
  42. printf("\n wrong speed!");
  43. }
  44.  
  45. while (height >= 0)
  46. {
  47. height = Height(deg, time, V);
  48. distance = horizontal(deg, time, V);
  49. printf("Time:%f S=%f H=%f\n", time, distance, height);
  50. time += 0.1;
  51. }
  52. _getch();
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement