#include<iostream.h>
#include<乱悄滚time.h>
#include<stdlib.h>
void
main()
{
int
i=0
float
a[13]={0}
srand((unsigned)time(null))
int
num1=0,num2=0
for(i=1i<=10000i++)
{
num1=rand()%6+1
num2=rand()%6+1
a[num1+num2]++
a[0]++
}
for(i=2i<=12i++)
{
cout<<i<<'
'<哗余<'
'
cout<<(a[i]/a[0])*100<<'%'
cout<<endl
}
}
# -*- coding: UTF-8 -*-import random,time
def randstr(x):
num=int(random.uniform(1,7))
return [num,"第" + str(x) + "个骰子摇出来的点如掘穗数是:" + str(num) + "\n"]
def tous(r):
sum,constr=0,""
# range(r) means 0 to r so use below
for i in range(1,r+1):
conresult=randstr(i)
sum+=conresult[0]
constr+=conresult[1]
return [sum,constr]
def calltous(k,v):
daxiao=("点数为小","点数为大渣卜")
result=tous(k)
print result[1] + "所有骰子摇得的总数是:" + str(result[0]) + "\n" + daxiao[(result[0]-v)>0] + "散帆\n"
while True:
calltous(3,10)
time.sleep(1.3)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)