Advertisement
emzone

Loops: Problem 4. Print a Deck of 52 Cards

Mar 30th, 2014
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 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).
  3. The cards should be printed using the classical notation (like 5♠, A♥, 9♣ and K♦). The card faces should start
  4. from 2 to A. Print each card face in its four possible suits: clubs, diamonds, hearts and spades.
  5. Use 2 nested for-loops and a switch-case statement.*/
  6.  
  7. using System;
  8. class PrintADeckOf52Cards
  9. {
  10.     static void Main()
  11.     {
  12.         string[] suits = new string[4] {"\u2663", "\u2666", "\u2665", "\u2660"};
  13.         string[] cards = new string[13] {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
  14.         for (int i = 0; i < cards.Length; i++)
  15.         {
  16.             for (int j = 0; j < suits.Length; j++)
  17.             {
  18.                 Console.Write(cards[i] + suits[j] + " ");    
  19.             }
  20.             Console.WriteLine();
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement