This code I wrote is supposed to find probability. However I keep getting compilation error that I am unable to understand and recognize. Help would be very much appreciated.
#include<iostream>
#include<stdio.h>
using namespace std;
float probability (float w,float b)
{
float p;
if(w+b > 1)
p = ((w*b*2)/(w+b+1)(w+b))*probability(w-1, b) + (2*b*(b-1)/(w+b+1)(w+b))*probability(w, b-2) + (2*w*(w-1)/(w+b+1)(w+b))*probability(w-1, b);
else if (w == 1 && b == 0)
p = 0;
else
p = 1;
return p;
}
int main()
{
float white, black;
cin>>white>>black;
float P = probability(white, black);
cout<<"The probability that Nishant wins is: "<<P<<endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire