骰子模拟问题
int main()
{
int arr[6] = {0,0,0,0,0,0};
for (int m = 0; m < 10000; m++)
{
int i = 1 + rand() % 6;
arr[i]++;
}
for(int n = 1; n <= 6; n++)
{
cout << n << "的个数有" << arr[n] << endl;
}
system("pause");
return 0;
}
最后输出6的个数是乱的
int main()
{
int arr[6] = {0,0,0,0,0,0};
for (int m = 0; m < 10000; m++)
{
int i = 1 + rand() % 6;
arr[i]++;
}
for(int n = 1; n <= 6; n++)
{
cout << n << "的个数有" << arr[n] << endl;
}
system("pause");
return 0;
}
最后输出6的个数是乱的
2017-04-10
举报