Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 C++ need help, my asgmt halfway =\

views
     
Avex
post Jan 28 2006, 01:40 AM

On my way
****
Junior Member
570 posts

Joined: Jan 2003
From: /k/ isle

give u some hint
use recursive
public static int c(int n, int k)
{
if(k==0 || k==n)
return 1;
return c(n-1, k-1) +c(n-1,k);
}

public static int c(int n, int k)
{
if(n<2 || k==0 || k==n) return 1;
int c=1;
for(int j=1; j<=k; j++)
{ c=c*(n-j+1)/j;
return c;
}


this code may not be relevant to your coding but the concept is almost the same...go figure. Don't ask me for any explanation ok wink.gif

This post has been edited by Avex: Jan 28 2006, 01:54 AM

 

Change to:
| Lo-Fi Version
0.0136sec    1.23    6 queries    GZIP Disabled
Time is now: 23rd December 2025 - 07:23 PM