JuliaPetkova

Untitled

Jun 4th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 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. int strNum = int.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.  
  32. if (i % 2 == 0)
  33. {
  34. if (i == strNum && score2 > score1)
  35. {
  36. winner = boat2;
  37. break;
  38. }
  39. else if (score2 >= 50)
  40. {
  41. winner = boat2;
  42. break;
  43. }
  44. else
  45. {
  46. score2 = score2 + speed.Length;
  47. }
  48. }
  49. else
  50. {
  51. if ((i == strNum) && (score1 > score2))
  52. {
  53. winner = boat1;
  54. break;
  55. }
  56. else if (score1 >= 50)
  57. {
  58. winner = boat1;
  59. break;
  60. }
  61. else
  62. {
  63. score1 = score1 + speed.Length;
  64. }
  65. }
  66. }
  67. Console.WriteLine(winner);
  68.  
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment