field trip problem trouble...help !

I wrote the following code…for field trip problem where probability of alice to enjoy the trip was to be found i.e when atleast k of her friends could go. but it gave RUNTIME ERROR …this is my second submission with this error in 2 days…im clueless .please help !


#include
using namespace std;
double fact(int n)
{
    int fac;
    fac=n*fact(n-1);
    return fac;
}
double comb(int a,int b)
{
    double temp;
    temp=fact(a)/(fact(b)*fact(a-b));
    return temp;
}
int main()
{
int t,s,n,k,m,r=0;
cout<>t;
cout<>n>>m>>k;
double ans1,a2[10],ans3,ans4;

while(t--)
{
    ans1=comb(s-k-1,n-k-1)/comb(s-k,n-k);
    ans3=comb(s-1,n-1)/comb(s,n);
    a2[r]=0;
    while(r<m-k+1)
    {
        a2[r]+=((comb(m-1,k)*comb(s-k,n-k))/comb(s,n));
    }
    ans4=(ans1*a2[r])/ans3;
    cout<<"probability for case is :\t"<<ans4;
}
return 0;
}

You dont need to output stuff like “Enter n,m,k”… Its all std input output… You can check the details about input output here… Tutorial for Input and Output | CodeChef

1 Like

i tried that too…it still wont work ! says…runtime error