Advertisement
Guest User

Untitled

a guest
Jun 24th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 16.17 KB | None | 0 0
  1. using System;
  2. class CardWarsBatka
  3. {
  4.     static void Main()
  5.     {
  6.         int numberOfGames = int.Parse(Console.ReadLine());
  7.         string[] cards = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "A", "J", "Q", "K"};
  8.         int firstPlayerScore = 0;
  9.         int secondPlayerScore = 0;
  10.         int firstPlayerWon = 0;
  11.         int secondPlayerWon = 0;
  12.         for (int i = 1; i <= numberOfGames; i++)
  13.         {
  14.             int currentFirstPlayerScore = 0;
  15.             int currentSecondPlayerScore = 0;
  16.             int firstPlayerCounterForZCard = 0;
  17.             int secondPlayerCounterForZCard = 0;
  18.             int firstPlayerCounterForYCard = 0;
  19.             int secondPlayerCounterForYCard = 0;
  20.             int firstPlayerCounterForXCard = 0;
  21.             int secondPlayerCounterForXCard = 0;
  22.  
  23.              
  24.             string firstPlayerFirstCard = (Console.ReadLine());
  25.             string firstPlayerSecondCard = (Console.ReadLine());
  26.             string firstPlayerThirdCard = (Console.ReadLine());
  27.  
  28.             string SecondPlayerFirstCard = (Console.ReadLine());
  29.             string SecondPlayerSecondCard = (Console.ReadLine());
  30.             string SecondPlayerThirdCard = (Console.ReadLine());
  31.  
  32.             if (firstPlayerFirstCard == "2")
  33.             {
  34.                 currentFirstPlayerScore += 10;
  35.             }
  36.             if (firstPlayerFirstCard == "3")
  37.             {
  38.                 currentFirstPlayerScore += 9;
  39.             }
  40.             if (firstPlayerFirstCard == "4")
  41.             {
  42.                 currentFirstPlayerScore += 8;
  43.             }
  44.             if (firstPlayerFirstCard == "5")
  45.             {
  46.                 currentFirstPlayerScore += 7;
  47.             }
  48.             if (firstPlayerFirstCard == "6")
  49.             {
  50.                 currentFirstPlayerScore += 6;
  51.             }
  52.             if (firstPlayerFirstCard == "7")
  53.             {
  54.                 currentFirstPlayerScore += 5;
  55.             }
  56.             if (firstPlayerFirstCard == "8")
  57.             {
  58.                 currentFirstPlayerScore += 4;
  59.             }
  60.             if (firstPlayerFirstCard == "9")
  61.             {
  62.                 currentFirstPlayerScore += 3;
  63.             }
  64.             if (firstPlayerFirstCard == "10")
  65.             {
  66.                 currentFirstPlayerScore += 2;
  67.             }
  68.             if (firstPlayerFirstCard == "A")
  69.             {
  70.                 currentFirstPlayerScore += 1;
  71.             }
  72.             if (firstPlayerFirstCard == "J")
  73.             {
  74.                 currentFirstPlayerScore += 11;
  75.             }
  76.             if (firstPlayerFirstCard == "Q")
  77.             {
  78.                 currentFirstPlayerScore += 12;
  79.             }
  80.             if (firstPlayerFirstCard == "K")
  81.             {
  82.                 currentFirstPlayerScore += 13;
  83.             }
  84.             if (firstPlayerFirstCard == "Z")
  85.             {
  86.                 firstPlayerCounterForZCard++;
  87.             }
  88.             if (firstPlayerFirstCard == "Y")
  89.             {
  90.                 firstPlayerCounterForYCard++;
  91.             }
  92.             if (firstPlayerFirstCard == "X")
  93.             {
  94.                 firstPlayerCounterForXCard++;
  95.             }
  96.  
  97.  
  98.             // second
  99.  
  100.  
  101.             if (firstPlayerSecondCard == "2")
  102.             {
  103.                 currentFirstPlayerScore += 10;
  104.             }
  105.             if (firstPlayerSecondCard == "3")
  106.             {
  107.                 currentFirstPlayerScore += 9;
  108.             }
  109.             if (firstPlayerSecondCard == "4")
  110.             {
  111.                 currentFirstPlayerScore += 8;
  112.             }
  113.             if (firstPlayerSecondCard == "5")
  114.             {
  115.                 currentFirstPlayerScore += 7;
  116.             }
  117.             if (firstPlayerSecondCard == "6")
  118.             {
  119.                 currentFirstPlayerScore += 6;
  120.             }
  121.             if (firstPlayerSecondCard == "7")
  122.             {
  123.                 currentFirstPlayerScore += 5;
  124.             }
  125.             if (firstPlayerSecondCard == "8")
  126.             {
  127.                 currentFirstPlayerScore += 4;
  128.             }
  129.             if (firstPlayerSecondCard == "9")
  130.             {
  131.                 currentFirstPlayerScore += 3;
  132.             }
  133.             if (firstPlayerSecondCard == "10")
  134.             {
  135.                 currentFirstPlayerScore += 2;
  136.             }
  137.             if (firstPlayerSecondCard == "A")
  138.             {
  139.                 currentFirstPlayerScore += 1;
  140.             }
  141.             if (firstPlayerSecondCard == "J")
  142.             {
  143.                 currentFirstPlayerScore += 11;
  144.             }
  145.             if (firstPlayerSecondCard == "Q")
  146.             {
  147.                 currentFirstPlayerScore += 12;
  148.             }
  149.             if (firstPlayerSecondCard == "K")
  150.             {
  151.                 currentFirstPlayerScore += 13;
  152.             }
  153.             if (firstPlayerSecondCard == "Z")
  154.             {
  155.                 firstPlayerCounterForZCard++;
  156.             }
  157.             if (firstPlayerSecondCard == "Y")
  158.             {
  159.                 firstPlayerCounterForYCard++;
  160.             }
  161.             if (firstPlayerSecondCard == "X")
  162.             {
  163.                 firstPlayerCounterForXCard++;
  164.             }
  165.  
  166.             // third
  167.  
  168.  
  169.             if (firstPlayerThirdCard == "2")
  170.             {
  171.                 currentFirstPlayerScore += 10;
  172.             }
  173.             if (firstPlayerThirdCard == "3")
  174.             {
  175.                 currentFirstPlayerScore += 9;
  176.             }
  177.             if (firstPlayerThirdCard == "4")
  178.             {
  179.                 currentFirstPlayerScore += 8;
  180.             }
  181.             if (firstPlayerThirdCard == "5")
  182.             {
  183.                 currentFirstPlayerScore += 7;
  184.             }
  185.             if (firstPlayerThirdCard == "6")
  186.             {
  187.                 currentFirstPlayerScore += 6;
  188.             }
  189.             if (firstPlayerThirdCard == "7")
  190.             {
  191.                 currentFirstPlayerScore += 5;
  192.             }
  193.             if (firstPlayerThirdCard == "8")
  194.             {
  195.                 currentFirstPlayerScore += 4;
  196.             }
  197.             if (firstPlayerThirdCard == "9")
  198.             {
  199.                 currentFirstPlayerScore += 3;
  200.             }
  201.             if (firstPlayerThirdCard == "10")
  202.             {
  203.                 currentFirstPlayerScore += 2;
  204.             }
  205.             if (firstPlayerThirdCard == "A")
  206.             {
  207.                 currentFirstPlayerScore += 1;
  208.             }
  209.             if (firstPlayerThirdCard == "J")
  210.             {
  211.                 currentFirstPlayerScore += 11;
  212.             }
  213.             if (firstPlayerThirdCard == "Q")
  214.             {
  215.                 currentFirstPlayerScore += 12;
  216.             }
  217.             if (firstPlayerThirdCard == "K")
  218.             {
  219.                 currentFirstPlayerScore += 13;
  220.             }
  221.             if (firstPlayerThirdCard == "Z")
  222.             {
  223.                 firstPlayerCounterForZCard++;
  224.             }
  225.             if (firstPlayerThirdCard == "Y")
  226.             {
  227.                 firstPlayerCounterForYCard++;
  228.             }
  229.             if (firstPlayerThirdCard == "X")
  230.             {
  231.                 firstPlayerCounterForXCard++;
  232.             }
  233.  
  234.              
  235.              
  236.  
  237.             // second player first hand
  238.  
  239.  
  240.             if (SecondPlayerFirstCard == "2")
  241.             {
  242.                 currentSecondPlayerScore += 10;
  243.             }
  244.             if (SecondPlayerFirstCard == "3")
  245.             {
  246.                 currentSecondPlayerScore += 9;
  247.             }
  248.             if (SecondPlayerFirstCard == "4")
  249.             {
  250.                 currentSecondPlayerScore += 8;
  251.             }
  252.             if (SecondPlayerFirstCard == "5")
  253.             {
  254.                 currentSecondPlayerScore += 7;
  255.             }
  256.             if (SecondPlayerFirstCard == "6")
  257.             {
  258.                 currentSecondPlayerScore += 6;
  259.             }
  260.             if (SecondPlayerFirstCard == "7")
  261.             {
  262.                 currentSecondPlayerScore += 5;
  263.             }
  264.             if (SecondPlayerFirstCard == "8")
  265.             {
  266.                 currentSecondPlayerScore += 4;
  267.             }
  268.             if (SecondPlayerFirstCard == "9")
  269.             {
  270.                 currentSecondPlayerScore += 3;
  271.             }
  272.             if (SecondPlayerFirstCard == "10")
  273.             {
  274.                 currentSecondPlayerScore += 2;
  275.             }
  276.             if (SecondPlayerFirstCard == "A")
  277.             {
  278.                 currentSecondPlayerScore += 1;
  279.             }
  280.             if (SecondPlayerFirstCard == "J")
  281.             {
  282.                 currentSecondPlayerScore += 11;
  283.             }
  284.             if (SecondPlayerFirstCard == "Q")
  285.             {
  286.                 currentSecondPlayerScore += 12;
  287.             }
  288.             if (SecondPlayerFirstCard == "K")
  289.             {
  290.                 currentSecondPlayerScore += 13;
  291.             }
  292.             if (SecondPlayerFirstCard == "Z")
  293.             {
  294.                 secondPlayerCounterForZCard++;
  295.             }
  296.             if (SecondPlayerFirstCard == "Y")
  297.             {
  298.                 secondPlayerCounterForYCard++;
  299.             }
  300.             if (SecondPlayerFirstCard == "X")
  301.             {
  302.                 secondPlayerCounterForXCard++;
  303.             }
  304.  
  305.              // seconod player second hand
  306.  
  307.  
  308.             if (SecondPlayerSecondCard == "2")
  309.             {
  310.                 currentSecondPlayerScore += 10;
  311.             }
  312.             if (SecondPlayerSecondCard == "3")
  313.             {
  314.                 currentSecondPlayerScore += 9;
  315.             }
  316.             if (SecondPlayerSecondCard == "4")
  317.             {
  318.                 currentSecondPlayerScore += 8;
  319.             }
  320.             if (SecondPlayerSecondCard == "5")
  321.             {
  322.                 currentSecondPlayerScore += 7;
  323.             }
  324.             if (SecondPlayerSecondCard == "6")
  325.             {
  326.                 currentSecondPlayerScore += 6;
  327.             }
  328.             if (SecondPlayerSecondCard == "7")
  329.             {
  330.                 currentSecondPlayerScore += 5;
  331.             }
  332.             if (SecondPlayerSecondCard == "8")
  333.             {
  334.                 currentSecondPlayerScore += 4;
  335.             }
  336.             if (SecondPlayerSecondCard == "9")
  337.             {
  338.                 currentSecondPlayerScore += 3;
  339.             }
  340.             if (SecondPlayerSecondCard == "10")
  341.             {
  342.                 currentSecondPlayerScore += 2;
  343.             }
  344.             if (SecondPlayerSecondCard == "A")
  345.             {
  346.                 currentSecondPlayerScore += 1;
  347.             }
  348.             if (SecondPlayerSecondCard == "J")
  349.             {
  350.                 currentSecondPlayerScore += 11;
  351.             }
  352.             if (SecondPlayerSecondCard == "Q")
  353.             {
  354.                 currentSecondPlayerScore += 12;
  355.             }
  356.             if (SecondPlayerSecondCard == "K")
  357.             {
  358.                 currentSecondPlayerScore += 13;
  359.             }
  360.             if (SecondPlayerSecondCard == "Z")
  361.             {
  362.                 secondPlayerCounterForZCard++;
  363.             }
  364.             if (SecondPlayerSecondCard == "Y")
  365.             {
  366.                 secondPlayerCounterForYCard++;
  367.             }
  368.             if (SecondPlayerSecondCard == "X")
  369.             {
  370.                 secondPlayerCounterForXCard++;
  371.             }
  372.  
  373.             //  second player third hand
  374.  
  375.  
  376.             if (SecondPlayerThirdCard == "2")
  377.             {
  378.                 currentSecondPlayerScore += 10;
  379.             }
  380.             if (SecondPlayerThirdCard == "3")
  381.             {
  382.                 currentSecondPlayerScore += 9;
  383.             }
  384.             if (SecondPlayerThirdCard == "4")
  385.             {
  386.                 currentSecondPlayerScore += 8;
  387.             }
  388.             if (SecondPlayerThirdCard == "5")
  389.             {
  390.                 currentSecondPlayerScore += 7;
  391.             }
  392.             if (SecondPlayerThirdCard == "6")
  393.             {
  394.                 currentSecondPlayerScore += 6;
  395.             }
  396.             if (SecondPlayerThirdCard == "7")
  397.             {
  398.                 currentSecondPlayerScore += 5;
  399.             }
  400.             if (SecondPlayerThirdCard == "8")
  401.             {
  402.                 currentSecondPlayerScore += 4;
  403.             }
  404.             if (SecondPlayerThirdCard == "9")
  405.             {
  406.                 currentSecondPlayerScore += 3;
  407.             }
  408.             if (SecondPlayerThirdCard == "10")
  409.             {
  410.                 currentSecondPlayerScore += 2;
  411.             }
  412.             if (SecondPlayerThirdCard == "A")
  413.             {
  414.                 currentSecondPlayerScore += 1;
  415.             }
  416.             if (SecondPlayerThirdCard == "J")
  417.             {
  418.                 currentSecondPlayerScore += 11;
  419.             }
  420.             if (SecondPlayerThirdCard == "Q")
  421.             {
  422.                 currentSecondPlayerScore += 12;
  423.             }
  424.             if (SecondPlayerThirdCard == "K")
  425.             {
  426.                 currentSecondPlayerScore += 13;
  427.             }
  428.             if (SecondPlayerThirdCard == "Z")
  429.             {
  430.                 secondPlayerCounterForZCard++;
  431.             }
  432.             if (SecondPlayerThirdCard == "Y")
  433.             {
  434.                 secondPlayerCounterForYCard++;
  435.             }
  436.             if (SecondPlayerThirdCard == "X")
  437.             {
  438.                 secondPlayerCounterForXCard++;
  439.             }
  440.  
  441.  
  442.              
  443.  
  444.              
  445.  
  446.              
  447.  
  448.             for (int c = 0; c < firstPlayerCounterForYCard; c++)
  449.             {
  450.                 firstPlayerScore -= 200;
  451.             }
  452.             for (int c = 0; c < firstPlayerCounterForZCard; c++)
  453.             {
  454.                 firstPlayerScore *= 2;
  455.             }
  456.  
  457.              
  458.  
  459.             for (int c = 0; c < secondPlayerCounterForYCard; c++)
  460.             {
  461.                 secondPlayerScore -= 200;
  462.             }
  463.             for (int c = 0; c < secondPlayerCounterForZCard; c++)
  464.             {
  465.                 secondPlayerScore *= 2;
  466.             }
  467.  
  468.             if (currentFirstPlayerScore == currentSecondPlayerScore)
  469.             {
  470.                 currentFirstPlayerScore = 0;
  471.                 currentSecondPlayerScore = 0;
  472.             }
  473.             else if (currentFirstPlayerScore > currentSecondPlayerScore)
  474.             {
  475.                 firstPlayerScore += currentFirstPlayerScore;
  476.             }
  477.             else if (currentSecondPlayerScore > currentFirstPlayerScore)
  478.             {
  479.                 secondPlayerScore += currentSecondPlayerScore;
  480.             }
  481.  
  482.  
  483.  
  484.             if (secondPlayerCounterForXCard > 0 || firstPlayerCounterForXCard > 0)
  485.             {
  486.                 if (firstPlayerCounterForXCard > secondPlayerCounterForXCard)
  487.                 {
  488.                     Console.WriteLine("X card drawn! Player one wins the match!");
  489.                     return;
  490.                 }
  491.                 else if (secondPlayerCounterForXCard > firstPlayerCounterForXCard)
  492.                 {
  493.                     Console.WriteLine("X card drawn! Player two wins the match!");
  494.                     return;
  495.                 }
  496.                 else if (secondPlayerCounterForXCard == firstPlayerCounterForXCard)
  497.                 {
  498.                     for (int C = 0; C < firstPlayerCounterForXCard; C++)
  499.                     {
  500.                         firstPlayerScore += 50;
  501.                         secondPlayerScore += 50;
  502.                     }
  503.                 }
  504.             }
  505.  
  506.              
  507.  
  508.              
  509.             if (currentFirstPlayerScore > currentSecondPlayerScore)
  510.             {
  511.                 firstPlayerWon++;
  512.             }
  513.             else if (currentSecondPlayerScore > currentFirstPlayerScore)
  514.             {
  515.                 secondPlayerWon++;
  516.             }
  517.              
  518.         }
  519.  
  520.         if (firstPlayerScore > secondPlayerScore)
  521.         {
  522.             Console.WriteLine("First player wins!");
  523.             Console.WriteLine("Score: {0}", firstPlayerScore);
  524.             Console.WriteLine("Games won: {0}", firstPlayerWon);
  525.         }
  526.         else if (secondPlayerScore > firstPlayerScore)
  527.         {
  528.             Console.WriteLine("Second player wins!");
  529.             Console.WriteLine("Score: {0}", secondPlayerScore);
  530.             Console.WriteLine("Games won: {0}", secondPlayerWon);
  531.         }
  532.         else
  533.         {
  534.             Console.WriteLine("It's a tie!");
  535.             Console.WriteLine("Score: {0}", firstPlayerScore);
  536.         }
  537.     }
  538. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement