fuliver123

[Quay lui] - Chia kαΊΉo

Feb 6th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int baby[3]={},count=1;
  4.  
  5. int div(int i0, int candy)
  6. {
  7.     int i;
  8.     if (candy==0)
  9.     {
  10.         if (baby[0]>0 && baby[1]>0 && baby[2]>0)
  11.         {
  12.             printf("%d. Chia keo: %d - %d - %d \n",count++,baby[0],baby[1],baby[2]);
  13.         }
  14.         return 0;
  15.     }
  16.     for (i=i0;i<=2;i++)
  17.     {
  18.         baby[i]++;
  19.         div(i,candy-1);
  20.         baby[i]--;
  21.     }
  22. }
  23.  
  24.  
  25. int main()
  26. {
  27.     div(0,87);
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment