Holey_yan

20140527_KUAS_VisualC++_Exam12

May 27th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. /************************************/
  2. /** 20140527 Exam 12               **/
  3. /** Maker  : Yan                   **/
  4. /** E-Mail : [email protected] **/
  5. /** Date   : 2014/05/27 am.11:40   **/
  6. /************************************/
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. int processing(int, int);
  12.  
  13. void main()
  14. {
  15.     int x = 0, y = 0;
  16.     printf("C(x, y), please input number of x & y.\n");
  17.     printf("Enter a number of x: ");
  18.     scanf("%d", &x);
  19.     printf("Enter a number of y: ");
  20.     scanf("%d", &y);
  21.     printf("Answer = %d.\n", processing(x, y));
  22.     system("pause");
  23. }
  24.  
  25. int processing(int x, int y)
  26. {
  27.     if((y == 0) || (x == y))
  28.     {
  29.         return 1;
  30.     }
  31.     else
  32.     {
  33.         return processing(x - 1, y) + processing(x - 1, y - 1);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment