Advertisement
svetoslavhl

CardWars

May 20th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. int N = int.Parse(Console.ReadLine());
  8.  
  9. string[] cardDeck = new string[13];
  10. int[] cardDeckValue = new int[13];
  11. cardDeck[0] = "2"; /*------------------>*/ cardDeckValue[0] = 10;
  12. cardDeck[1] = "3"; /*------------------>*/ cardDeckValue[1] = 9;
  13. cardDeck[2] = "4"; /*------------------>*/ cardDeckValue[2] = 8;
  14. cardDeck[3] = "5"; /*------------------>*/ cardDeckValue[3] = 7;
  15. cardDeck[4] = "6"; /*------------------>*/ cardDeckValue[4] = 6;
  16. cardDeck[5] = "7"; /*------------------>*/ cardDeckValue[5] = 5;
  17. cardDeck[6] = "8"; /*------------------>*/ cardDeckValue[6] = 4;
  18. cardDeck[7] = "9"; /*------------------>*/ cardDeckValue[7] = 3;
  19. cardDeck[8] = "10"; /*------------------>*/ cardDeckValue[8] = 2;
  20.  
  21.  
  22. cardDeck[9] = "A"; /*------------------>*/ cardDeckValue[9] = 1;
  23. cardDeck[10] = "J"; /*------------------>*/ cardDeckValue[10] = 11;
  24. cardDeck[11] = "Q"; /*------------------>*/ cardDeckValue[11] = 12;
  25. cardDeck[12] = "K"; /*------------------>*/ cardDeckValue[12] = 13;
  26.  
  27. int peshoCurrentScores = 0;
  28. int goshoCurrentScores = 0;
  29.  
  30. int peshoScores = 0;
  31. int goshoScores = 0;
  32.  
  33. int peshoGamesWon = 0;
  34. int goshoGamesWon = 0;
  35.  
  36.  
  37.  
  38.  
  39.  
  40. while (N > 0)
  41. {
  42. // VKARVAME KARTITE NA PESHO I GOSHO
  43. string peshoCard1 = Console.ReadLine();
  44. string peshoCard2 = Console.ReadLine();
  45. string peshoCard3 = Console.ReadLine();
  46.  
  47. string goshoCard1 = Console.ReadLine();
  48. string goshoCard2 = Console.ReadLine();
  49. string goshoCard3 = Console.ReadLine();
  50.  
  51. //RESTARTIRAME MOMENTNITE IM STOINOSTI
  52.  
  53. peshoCurrentScores = 0;
  54. goshoCurrentScores = 0;
  55.  
  56.  
  57.  
  58. for (int i = 0; i < 13; i++)
  59. {
  60.  
  61. if (cardDeck[i] == peshoCard1)
  62. {
  63.  
  64. peshoCurrentScores += cardDeckValue[i];
  65.  
  66. }
  67.  
  68. if (cardDeck[i] == goshoCard1)
  69. {
  70.  
  71. goshoCurrentScores += cardDeckValue[i];
  72. }
  73.  
  74. }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. for (int i = 0; i < 13; i++)
  82. {
  83.  
  84. if (cardDeck[i] == peshoCard2)
  85. {
  86. peshoCurrentScores += cardDeckValue[i];
  87.  
  88. }
  89.  
  90. if (cardDeck[i] == goshoCard2)
  91. {
  92.  
  93. goshoCurrentScores += cardDeckValue[i];
  94. }
  95.  
  96. }
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103. for (int i = 0; i < 13; i++)
  104. {
  105.  
  106. if (cardDeck[i] == peshoCard3)
  107. {
  108.  
  109. peshoCurrentScores += cardDeckValue[i];
  110.  
  111. }
  112.  
  113. if (cardDeck[i] == goshoCard3)
  114. {
  115.  
  116. goshoCurrentScores += cardDeckValue[i];
  117. }
  118.  
  119. }
  120.  
  121.  
  122.  
  123. if (peshoCurrentScores > goshoCurrentScores)
  124. {
  125.  
  126. peshoScores += peshoCurrentScores;
  127. peshoGamesWon++;
  128.  
  129.  
  130. }
  131.  
  132. if (goshoCurrentScores > peshoCurrentScores)
  133. {
  134.  
  135. goshoScores += goshoCurrentScores;
  136. goshoGamesWon++;
  137.  
  138. }
  139.  
  140.  
  141.  
  142. N--;
  143.  
  144.  
  145. }
  146.  
  147.  
  148.  
  149.  
  150.  
  151. if (peshoScores > goshoScores)
  152. {
  153.  
  154. Console.WriteLine("Firts player wins !");
  155. Console.WriteLine("Score: {0}", peshoScores);
  156. Console.WriteLine("Games won: {0}", peshoGamesWon);
  157.  
  158. }
  159.  
  160. if (goshoScores > peshoScores)
  161. {
  162.  
  163. Console.WriteLine("Second player wins !");
  164. Console.WriteLine("Score: {0}", goshoScores);
  165. Console.WriteLine("Games won: {0}", goshoGamesWon);
  166.  
  167. }
  168.  
  169. if (goshoScores == peshoScores)
  170. {
  171.  
  172. Console.WriteLine("It's a tie !");
  173. Console.WriteLine("Score: {0}", goshoScores);
  174.  
  175.  
  176. }
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186. }
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement