标签:http style class ace src cas col inf ast
#include<iostream> #include<cstdlib> #include<ctime> using namespace std; class Dice{ public: Dice(int n); int cast(); private: int sides; }; Dice::Dice(int n){ sides=n; } int Dice::cast(){ return rand()%sides+1; } int main(){ int a,b,i=0; srand((unsigned)time(NULL)); Dice d1(40); for(a=1;a<=400;a++){ b=d1.cast(); if(b==17){ i++; } } cout<<i<<endl; }
标签:http style class ace src cas col inf ast
原文地址:https://www.cnblogs.com/haruna/p/9080054.html