Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Cards
  5. {
  6.     static void Main()
  7.     {
  8.         int linesCount = int.Parse(Console.ReadLine());
  9.  
  10.         int[] totalDeck = new int[52];
  11.         for (int i = 0; i < linesCount; i++)
  12.         {
  13.             long currentHand = long.Parse(Console.ReadLine());
  14.  
  15.             for (int position = 0; position < 52; position++)
  16.             {
  17.                 long currentBit = (currentHand >> position) & 1;
  18.                 if (currentBit == 1)
  19.                 {
  20.                     totalDeck[position]++;
  21.                 }
  22.             }
  23.         }
  24.         //get numbers with odd occurences
  25.         List<string> oddOccurences = GetOddOccurences(totalDeck);
  26.         bool weHaveFullDeck = true;
  27.         //check if we have full deck
  28.         foreach (var card in totalDeck)
  29.         {
  30.             if (card <= 0)
  31.             {
  32.                 weHaveFullDeck = false;
  33.                 break;
  34.             }
  35.         }
  36.  
  37.         if (weHaveFullDeck)
  38.         {
  39.             Console.WriteLine("Full deck");
  40.         }
  41.         else
  42.         {
  43.             Console.WriteLine("Wa wa!");
  44.         }
  45.  
  46.         Console.WriteLine(string.Join(" ",oddOccurences));
  47.  
  48.     }
  49.  
  50.     private static List<string> GetOddOccurences(int[] totalDeck)
  51.     {
  52.         var oddOccurences = new List<string>();
  53.         string[] cards =
  54.         {
  55.             "2c","3c","4c","5c","6c","7c","8c","9c","Tc","Jc","Qc","Kc","Ac",
  56.              "2d","3d","4d","5d","6d","7d","8d","9d","Td","Jd","Qd","Kd","Ad",
  57.              "2h","3h","4h","5h","6h","7h","8h","9h","Th","Jh","Qh","Kh","Ah",
  58.              "2s","3s","4s","5s","6s","7s","8s","9s","Ts","Js","Qs","Ks","As",
  59.  
  60.         };
  61.         for (int i = 0; i < totalDeck.Length; i++)
  62.         {
  63.             if (totalDeck[i] % 2 == 1)
  64.             {
  65.                 oddOccurences.Add(cards[i]);
  66.             }
  67.         }
  68.  
  69.         return oddOccurences;
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement