Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li>We have to count occurance of each number and then visualize it as histogram. </li> <li>We actually should use dictionary for each number and count its stats. </li> <li>But in our case we can use array, too.Cause we know that our numbers will be within (1-5) <code>{1,2,3,4,5}</code>.So we will make 5 length array.Then we will just store <code>number</code> stats at <code>(number-1)</code> index.</li> <li>Then when using we will know that stats at <code>array[index]</code> will be our <code>number //number=(index+1)</code> stats</li> </ul> <p>Now the same things with code for 100 tries:</p> <pre><code> //make randomized 100 tries with {1,2,3,4,5} numbers Random rnd = new Random(); int[] RandomArray = new int[100]; for (int i = 0; i &lt; 100; ++i) RandomArray[i] = rnd.Next(1, 6); // //Now lets count of occurance of each number int[] Count = new int[5]; for (int i = 0; i &lt; 100; ++i){ // Count[RandomArray[i]-1]++; int number=RandomArray[i];//get our number from randomized box int index=number-1; // number stats will store at (number-1) index //in our case we will increase our number count ++Count[index] ;//Count[index]+=1 } </code></pre> <p>And when visualizing those as histogram we will get stats to our number using (index+1). </p> <pre><code> for (int i = 0; i &lt; 5; ++i){ //number=i+1 and its stat will be at Count[i] Console.Write("{0,2} Adet {1,2} &gt;&gt;&gt;&gt;", Count[i], i+1); for (int j = 0; j &lt; Count[i]; j++) { Console.Write("*"); } Console.WriteLine(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload