JuliaPetkova

Untitled

Jun 4th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _4_3_14_BoatSimulator
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. char boat1 = char.Parse(Console.ReadLine());
  14. char boat2 = char.Parse(Console.ReadLine());
  15.  
  16. byte strNum = byte.Parse(Console.ReadLine());
  17.  
  18. int score1 = 0;
  19. int score2 = 0;
  20. char winner = ' ';
  21.  
  22. for (int i = 1; i <= strNum; i++)
  23. {
  24. string speed = Console.ReadLine();
  25.  
  26. if (speed == "UPGRADE")
  27. {
  28. boat1 += (char)3;
  29. boat2 += (char)3;
  30. }
  31. else
  32. {
  33. if (i % 2 == 0)
  34. {
  35. if (i == strNum && score2 > score1)
  36. {
  37. winner = boat2;
  38. break;
  39. }
  40. else if (score2 >= 50)
  41. {
  42. winner = boat2;
  43. break;
  44. }
  45. else
  46. {
  47. score2 = score2 + speed.Length;
  48. }
  49. }
  50. else
  51. {
  52. if ((i == strNum) && (score1 > score2))
  53. {
  54. winner = boat1;
  55. break;
  56. }
  57. else if (score1 >= 50)
  58. {
  59. winner = boat1;
  60. break;
  61. }
  62. else
  63. {
  64. score1 = score1 + speed.Length;
  65. }
  66. }
  67. }
  68. }
  69. Console.WriteLine(winner);
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment