标签:public turn ice inf .com cas temp for png
#include<iostream>
#include<cstdlib>
using namespace std;
class Dice {
public:
Dice(int n);
friend int cast(Dice &p1);
private:
int sides;
};
Dice::Dice(int n)
{
sides=n;
}
int cast(Dice &p1)
{
return rand()%p1.sides;
}
int main()
{
int i,n=0,temp,num;
cin>>i;//输入面数
cin>>num;//输入学号
Dice a(i);
for(int j=0;j<500;j++)
{
temp=cast(a);
if(temp==num)
n++;
}
cout<<n<<"/500";
return 0;
}
运行截图:
标签:public turn ice inf .com cas temp for png
原文地址:https://www.cnblogs.com/zengiai/p/9007364.html