Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- System.Random aleatoire = new System.Random();
- int lancers = int.Parse(Console.ReadLine());
- int[] nombreCotes = new int[12];
- for (int i = 0; i <= lancers; i++)
- {
- int t =System.Convert.ToInt32(aleatoire.NextDouble() * 6);
- int u = System.Convert.ToInt32(aleatoire.NextDouble() * 6);
- switch (t+u)
- {
- case 1:
- nombreCotes[0] = nombreCotes[0] + 1;
- break;
- case 2:
- nombreCotes[1] = nombreCotes[1] + 1;
- break;
- case 3:
- nombreCotes[2] = nombreCotes[2] + 1;
- break;
- case 4:
- nombreCotes[3] = nombreCotes[3] + 1;
- break;
- case 5:
- nombreCotes[4] = nombreCotes[4] + 1;
- break;
- case 6:
- nombreCotes[5] = nombreCotes[5] + 1;
- break;
- case 7:
- nombreCotes[6] = nombreCotes[6] + 1;
- break;
- case 8:
- nombreCotes[7] = nombreCotes[7] + 1;
- break;
- case 9:
- nombreCotes[8] = nombreCotes[8] + 1;
- break;
- case 10:
- nombreCotes[9] = nombreCotes[9] + 1;
- break;
- case 11:
- nombreCotes[10] = nombreCotes[10] + 1;
- break;
- case 12:
- nombreCotes[11] = nombreCotes[11] + 1;
- break;
- }
- }
- double total = 0;
- for (int i = 1; i <= 12; i++)
- {
- double frequence = System.Convert.ToDouble(nombreCotes[i - 1]) / System.Convert.ToDouble(lancers);
- Console.WriteLine("Pour " + i + ", l'effectif est de : " + nombreCotes[i-1] + ", la fréquence est de " + frequence);
- total = total + frequence;
- }
- Console.WriteLine(total);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment