Advertisement
AnitaN

06.LoopsHomework/04.1.PrintDeck52CardsVariant

Mar 29th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. //Problem 4.    Print a Deck of 52 Cards
  2. //Write a program that generates and prints all possible cards from a standard deck of 52 cards (without the jokers). The cards should be printed using the classical notation (like 5♠, A♥, 9♣ and K♦). The card faces should start from 2 to A. Print each card face in its four possible suits: clubs, diamonds, hearts and spades.
  3.  
  4. //This is variant with arrays
  5. using System;
  6.  
  7. class PrintDeck52CardsVariant
  8. {
  9.     static void Main()
  10.     {
  11.         //Arrays
  12.         string[] cards = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" };
  13.         int[] colors = { 3, 4, 5, 6 };
  14.  
  15.         foreach (var card in cards)
  16.         {
  17.             foreach (var color in colors)
  18.             {
  19.                 Console.Write(card);
  20.                 Console.Write((char)color + " ");
  21.             }
  22.             Console.WriteLine();
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement