Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
AnswerRe: North wind Database Pin
Marco Bertschi3-Feb-14 21:04
protectorMarco Bertschi3-Feb-14 21:04 
QuestionWorking with Bitmaps Pin
BBatts3-Feb-14 7:45
BBatts3-Feb-14 7:45 
AnswerRe: Working with Bitmaps Pin
TnTinMn4-Feb-14 6:56
TnTinMn4-Feb-14 6:56 
QuestionProject Question Pin
reaper21913-Feb-14 5:15
reaper21913-Feb-14 5:15 
AnswerRe: Project Question Pin
Alan Balkany3-Feb-14 5:20
Alan Balkany3-Feb-14 5:20 
AnswerRe: Project Question Pin
Pete O'Hanlon3-Feb-14 5:48
mvePete O'Hanlon3-Feb-14 5:48 
AnswerRe: Project Question Pin
OriginalGriff3-Feb-14 6:11
mveOriginalGriff3-Feb-14 6:11 
GeneralRe: Project Question Pin
reaper21913-Feb-14 6:20
reaper21913-Feb-14 6:20 
This is what I am trying to do with this:
Write a C# program to simulate the drawing from a deck of 52 poker cards valued from 1 to 13 with 4 suits. One round of drawing consists of randomly pull any 4 cards from the 52-card deck. Therefore, the same card cannot appeared more than once. The program will perform 10,000 rounds of drawing and tallying the frequencies of the following possible results for the 4 cards pulled: (a)the 4 cards are having the same suit, (b)the 4 cards are from the 4 different suits, (c)the 4 cards are having the same value, (d)3 cards have the same value, (e)exactly 2 different pairs of 2 same-value cards, and (f)only 2 cards have the same value. Notice that (b) may occurred together with (c) - (f).

This is what I have so far:
C#
using System;

namespace Draw4
{
    class Program
    {
        static int[] ranData = new int[4];
        static Random ran = new Random();
        static int[] KS = new int[4];

        static int GenerateRandomNum()
        {
            int cleanRanNum;
            cleanRanNum = ran.Next(1, 53);
            
            // Prevent cards from repeating

            return cleanRanNum;
        }
        static void Main(string[] args)
        {
            int idx, ranNum;
            int[] cdv = new int[4]; // 1-13
            int[] cds = new int[4]; // 1-4
            for (idx = 0; idx < 4; idx++) KS[idx] = 0;
            // loop 10,000 times
            //for (int lp = 0; lp < 10000; lp++)
            {
                // Draw 4 cards

                Console.Write("Random numbers: \t");
                for (idx = 0; idx < cdv.Length; idx++)
                {
                    ranNum = GenerateRandomNum();

                    Console.Write(ranNum + ",\t");
                    cdv[idx] = ranNum % 13;
                    if (cdv[idx] == 0)
                    {
                        cds[idx] = ranNum / 13;
                        cdv[idx] = 13;
                    }
                    else
                        cds[idx] = ranNum / 13 + 1;

                }
                Array.Sort(cdv);
                Console.Write("\nThe suits:\t\t");
                PrintingSuits(cds);
                Console.Write("\nThe values:\t\t");

                foreach (int val in cdv) Console.Write(val + ",\t");
                CountSuits(cds);
            }
            Console.Read();
        }
        static void CountSuits(int[] cds)
        {
            Array.Sort(cds);
            int howManySuits = 0;
            for (int j = 0; j < 3; j++)
                if (cds[j] != cds[j + 1]) howManySuits++;
            Console.WriteLine("\nThis hand has {0} suits", howManySuits + 1);
            return;

        }
        static void PrintingSuits(int[] suit)
        {
            string s = " ";
            foreach (int su in suit)
            {

                switch (su)
                {
                    case 1: s = "H"; break;
                    case 2: s = "S"; break;
                    case 3: s = "D"; break;
                    case 4: s = "C"; break;
                }

                Console.Write(s + ",\t");
            }
        }
    }
}

GeneralRe: Project Question Pin
OriginalGriff3-Feb-14 6:43
mveOriginalGriff3-Feb-14 6:43 
GeneralRe: Project Question Pin
Matt T Heffron3-Feb-14 8:06
professionalMatt T Heffron3-Feb-14 8:06 
GeneralRe: Project Question Pin
reaper21913-Feb-14 17:09
reaper21913-Feb-14 17:09 
AnswerRe: Project Question Pin
Matt T Heffron3-Feb-14 18:44
professionalMatt T Heffron3-Feb-14 18:44 
AnswerRe: Project Question Pin
V.3-Feb-14 20:22
professionalV.3-Feb-14 20:22 
QuestionCreating a small project using C# - Please Help Pin
Mohan Subramani3-Feb-14 0:11
Mohan Subramani3-Feb-14 0:11 
AnswerRe: Creating a small project using C# - Please Help Pin
Pete O'Hanlon3-Feb-14 0:18
mvePete O'Hanlon3-Feb-14 0:18 
QuestionRe: Creating a small project using C# - Please Help Pin
Mohan Subramani3-Feb-14 1:02
Mohan Subramani3-Feb-14 1:02 
AnswerRe: Creating a small project using C# - Please Help Pin
Richard MacCutchan3-Feb-14 0:22
mveRichard MacCutchan3-Feb-14 0:22 
QuestionRe: Creating a small project using C# - Please Help Pin
Mohan Subramani3-Feb-14 1:16
Mohan Subramani3-Feb-14 1:16 
AnswerRe: Creating a small project using C# - Please Help Pin
Richard MacCutchan3-Feb-14 2:18
mveRichard MacCutchan3-Feb-14 2:18 
GeneralRe: Creating a small project using C# - Please Help Pin
Mohan Subramani3-Feb-14 2:48
Mohan Subramani3-Feb-14 2:48 
JokeRe: Creating a small project using C# - Please Help Pin
Ravi Bhavnani3-Feb-14 6:15
professionalRavi Bhavnani3-Feb-14 6:15 
GeneralIssues in creating SQL Server Database with C# windows Application Pin
Mohan Subramani4-Feb-14 3:15
Mohan Subramani4-Feb-14 3:15 
GeneralRe: Issues in creating SQL Server Database with C# windows Application Pin
Ravi Bhavnani4-Feb-14 6:24
professionalRavi Bhavnani4-Feb-14 6:24 
AnswerRe: Creating a small project using C# - Please Help Pin
John D. Sanders4-Feb-14 9:13
John D. Sanders4-Feb-14 9:13 
QuestionArtificial Neural Network Pin
Member 95388301-Feb-14 23:34
Member 95388301-Feb-14 23:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.