Advertisement
Tervel

Race Cars

Feb 19th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Car_RaceTest
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string[] race = Console.ReadLine().Split();
  10.  
  11. double[] leftCar = new double[race.Length / 2];
  12. double[] rightCar = new double[race.Length / 2];
  13.  
  14. double leftCarTime = 0;
  15. double rightCarTime = 0;
  16. string winer = "";
  17. double winerTime = 0;
  18.  
  19. for (int i = 0; i < race.Length / 2; i++)
  20. {
  21. leftCar[i] = double.Parse(race[i]);
  22. rightCar[i] = double.Parse(race[race.Length - i - 1]);
  23.  
  24. leftCarTime += leftCar[i];
  25. rightCarTime += rightCar[i];
  26.  
  27. if (leftCar[i] == 0)
  28. {
  29. leftCarTime *= 0.80;
  30. }
  31. if (rightCar[i] == 0)
  32. {
  33. rightCarTime *= 0.80;
  34. }
  35.  
  36. }
  37. if (leftCarTime < rightCarTime)
  38. {
  39. winer = "left";
  40. Console.WriteLine($"The winner is {winer} with total time: {leftCarTime:f1}");
  41. }
  42. else
  43. {
  44. winer = "right";
  45. Console.WriteLine($"The winner is {winer} with total time: {rightCarTime:f1}");
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement