Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class PrintADeckOf52Cards
- {
- static void Main()
- {
- int[] suits = new int[] { 5, 4, 3, 6 };
- for (int i = 2; i < 15; i++)
- {
- for (int suit = 3; suit < 7; suit++)
- {
- // The following if statements are used to temporarily swap the suit with the one that is in the correct order so the output is as in the example.
- if (suit == 3) //ето тук почва 'балъшката част' :)
- {
- int temp = suit;
- suit = suits[0];
- WriteToConsole(i, suit);
- suit = temp;
- }
- else if (suit == 4)
- {
- int temp = suit;
- suit = suits[1];
- WriteToConsole(i, suit);
- suit = temp;
- }
- else if (suit == 5)
- {
- int temp = suit;
- suit = suits[2];
- WriteToConsole(i, suit);
- suit = temp;
- }
- else
- {
- int temp = suit;
- suit = suits[3];
- WriteToConsole(i, suit);
- }
- }
- Console.WriteLine();
- }
- }
- static void WriteToConsole(int i, int suit)
- {
- switch (i)
- {
- default: Console.Write("".PadLeft(2, ' ') + i + "" + (char)(suit) + " ".PadRight(2, ' ')); break; // поиграл съм си да ми се подредят красиво :)
- case 10: Console.Write("".PadLeft(1, ' ') + "10" + (char)(suit) + " "); break;
- case 11: Console.Write("".PadLeft(2, ' ') + "J" + (char)(suit) + " "); break;
- case 12: Console.Write("".PadLeft(2, ' ') + "Q" + (char)(suit) + " "); break;
- case 13: Console.Write("".PadLeft(2, ' ') + "K" + (char)(suit) + " "); break;
- case 14: Console.Write("".PadLeft(2, ' ') + "A" + (char)(suit) + " "); break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment