寻找“骰子”的c语言算法或代码...
是“掷骰子”,对吧?!!这是掷骰子的程序:题目是这样的:写一个程序模拟掷骰子,每个骰子是从1-6,所以两个骰子组合的个数是从2-12,随机掷出10000次,打印出所有组合的概率!
# include & ltiostream.h & gt
# include & lttime.h & gt
# include & ltstdlib.h & gt
空的
主()
{
(同Internationalorganizations)国际组织
I = 0;
漂浮物
a[13]= { 0 };
srand((无符号)时间(空));
(同Internationalorganizations)国际组织
num1=0,num 2 = 0;
for(I = 1;我& lt=10000;i++)
{
num 1 = rand()% 6+1;
num 2 = rand()% 6+1;
a[num 1+num 2]++;
a[0]++;
}
for(I = 2;我& lt=12;i++)
{
cout & lt& lt我& lt& lt'
& lt& lt'
;
cout & lt& lt(a[I]/a[0])* 100 & lt;& lt'%';
cout & lt& ltendl
}
}