Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- class PrintFullDeckOfCards
- {
- static void Main()
- {
- /*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. Use 2 nested
- * for-loops and a switch-case statement.*/
- Console.OutputEncoding = Encoding.UTF8;
- char clubs = '\u2663';
- char diamonds = '\u2666';
- char hearts = '\u2665';
- char spades = '\u2660';
- char[] suits = new char[] { clubs, diamonds, hearts, spades };
- string jack = "J";
- string queen = "Q";
- string knight = "K";
- string ace = "A";
- for (int i = 2; i <= 14; i++)
- {
- for (int j = 1; j <= 4; j++)
- {
- switch (i)
- {
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- {
- Console.Write(i + "{0} ", suits[j - 1]);
- break;
- }
- case 11: Console.Write(jack + "{0} ", suits[j - 1]); break;
- case 12: Console.Write(queen + "{0} ", suits[j - 1]); break;
- case 13: Console.Write(knight + "{0} ", suits[j - 1]); break;
- case 14: Console.Write(ace + "{0} ", suits[j - 1]); break;
- }
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment