1、#include#include#includeusing namespace std;int main()int a,b,str36000,t2=0,t3=0,t4=0,t5=0,t6=0,t7=0,t8=0,t9=0,t10=0,t11=0,t12=0,n;coutn;for(int i=0;in;i+)a=(rand()%6)+1;b=(rand()%6)+1;stri=a+b;if(a+b=2)t2+;if(a+b=3)t3+;if(a+b=4)t4+;if(a+b=5)t5+;if(a+b=6)t6+;if(a+b=7)t7+;if(a+b=8)t8+;if(a+b=9)t9+;if
2、(a+b=10)t10+;if(a+b=11)t11+;if(a+b=12)t12+;cout“测试结果:n“;for(i=0;in;i+)coutsetiosflags(ios:left)setw(8)stri;coutendl;cout“ Sum Total Expected Actualen“;cout“ “2“ “t2“ “(float)1/36“ “(float)t2/nendl;cout“ “3“ “t3“ “(float)2/36“ “(float)t3/nendl;cout“ “4“ “t4“ “(float)3/36“ “(float)t4/nendl;cout“ “5“ “
3、t5“ “(float)4/36“ “(float)t5/nendl;cout“ “6“ “t6“ “(float)5/36“ “(float)t6/nendl;cout“ “7“ “t7“ “(float)6/36“ “(float)t7/nendl;cout“ “8“ “t8“ “(float)5/36“ “(float)t8/nendl;cout“ “9“ “t9“ “(float)4/36“ “(float)t9/nendl;cout“ “10“ “t10“ “(float)3/36“ “(float)t10/nendl;cout“ “11“ “t11“ “(float)2/36“ “(float)t11/nendl;cout“ “12“ “t12“ “(float)1/36“ “(float)t12/nendl;return 0;