admin管理员组

文章数量:1585963

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>

using namespace std;

int main()
{
	int n;
	cout << "请输入执行次数:" << endl;
	cin >> n;

	int a[6] = { 0 };

	for (int i = 0; i < n; i++)
	{
		// a[rand() % 6]++;
		for (int j = 0; j < 6; j++)
		{
			if (rand() % 6  == j )
			{
				a[j]++;
			}

		}
	}

	for (int j = 0; j < 6; j++)
	{
		printf("%d号的概率为:%lf\%\n", j+1, a[j] * 1.0 / n);
	}
	//for (int i = 0; i < 2; i++)
	//{
	//	cout << rand() % 6+1<<endl ;
	//}

	return 0;
}

本文标签: 随机数生成器概率宿舍