Thread: how to pick the basic cases for this function..

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    how to pick the basic cases for this function..

    in order to know what it does
    Code:
    void what(int n, int limit, int* answer, int place){ 
    int i;
       	if (n > 0)
    	   for (i=min(n,limit); i>0; i--){
    		   answer[place]=i; 
    		   answer[place+1]=-1;
    		   what(n-i, i, answer, place+1);
    		   answer[place]=-1;
    	   }
       	else{
    	   for (i=0; answer[i]!=-1; i++)
    		printf("%d ", answer[i]);
    	   printf("\n");
       	}
     }

  2. #2
    apprentiCe
    Join Date
    Oct 2008
    Location
    Hyderabad,India
    Posts
    136
    call the function in main() function with different values of n and place(preferably at boundary values) and observe the output
    Code:
    printf("%c%c%c%c%c%c%c",0x68,0x68^0xd,0x68|0x4,0x68|0x4,0x68|0xf,0x68^0x49,0x68^0x62);

  3. #3
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    what numbers would you input in order to find what it does?

  4. #4
    apprentiCe
    Join Date
    Oct 2008
    Location
    Hyderabad,India
    Posts
    136
    n=-1 and n=0 and n=1 for starters, as right at the beginning you got n>0

    though its really hard for me to tell...as i dont have any idea what its about...its upto you...actually
    Code:
    printf("%c%c%c%c%c%c%c",0x68,0x68^0xd,0x68|0x4,0x68|0x4,0x68|0xf,0x68^0x49,0x68^0x62);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM