n个骰子的点数

#include
using namespace std;

int countTimes(int newSum,int newDiceNum);

void printProba_recusive(const int diceNum)
{
    if(diceNum<=0)
    {
        return;
    }
    double *probaArray = new double[5*diceNum+1];
	double base=pow((double)6,double(diceNum));
    for(int sum=diceNum;sum<=6*diceNum;sum++)
    {
        probaArray[sum-diceNum]=countTimes(sum,diceNum)/base;
		cout<=1 && newSum<=6)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
	int ret1=countTimes(newSum-1,newDiceNum-1);
	int ret2=countTimes(newSum-2,newDiceNum-1);
	int ret3=countTimes(newSum-3,newDiceNum-1);
	int ret4=countTimes(newSum-4,newDiceNum-1);
	int ret5=countTimes(newSum-5,newDiceNum-1);
	int ret6=countTimes(newSum-6,newDiceNum-1);
	return ret1+ret2+ret3+ret4+ret5+ret6;
}
int main()
{
    printProba_recusive(1);
	cout<

你可能感兴趣的:(编程练习,递归)