Advertisement
Laudanum-user

Untitled

Oct 30th, 2022
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. Console.WriteLine("Task: I_3");
  2.  
  3. static double S(double v, double a, double t)
  4. {
  5.     return v * t + a * t * t / 2;
  6. }
  7.  
  8. static double tt(double v1, double a1, double v2, double a2)
  9. {
  10.     //S1 = v1*t + a1*t*t/2 == S2 = v2*t + a2*t*t/2
  11.     //(a2-a1)*t*t + 2*(v2-v1)*t == 0. t > 0
  12.     //(a2-a1)*t = -2 * (v2-v1)
  13.     return -2 * (v2 - v1) / (a2 - a1);
  14. }
  15.  
  16. double s11 = S(10, 1, 1), s12 = S(9, 1.6, 1), s21 = S(10, 1, 4), s22 = S(9, 1.6, 4);
  17. string c1 = s11 > s12 ? ">" : (s11 < s12 ? "<" : "=="),
  18.     c2 = s21 > s22 ? ">" : (s21 < s22 ? "<" : "==");
  19. Console.WriteLine("At 1 hour: first made {0} which is " + c1 + " than second's {1}", s11, s12);
  20. Console.WriteLine("At 4 hours: first made {0} which is " + c2 + " than second's {1}", s21, s22);
  21. Console.WriteLine("They'll meet at {0:0.##} hours", tt(10, 1, 9, 1.6));
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement