scorici

99-bottles

Nov 14th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. void bottles(int n)
  4. {
  5.     printf("%d bottles of beer on the wall, %d bottles of beer, ", n, n);
  6.     printf("ya’ take one down, ya’ pass it around, ");
  7.     printf("%d bottles of beer on the wall.\n", n-1);
  8.     //bottle(n-1);
  9. }
  10. void bottle(int n)
  11. {
  12.     if (n > 1)
  13.     {
  14.         bottles(n);
  15.         bottle(n-1);
  16.     }
  17.     else if (n == 1)
  18.     {
  19.         bottles(n);
  20.         bottle(n-1);
  21.     }
  22.     else
  23.     {
  24.         printf("No bottles of beer on the wall, no bottles of beer, ");
  25.         printf("ya’ can’t take one down, ya’ can’t pass it around, ");
  26.         printf("cause there are no more bottles of beer on the wall!\n");
  27.     }
  28. }
  29.  
  30. int main(void)
  31. {
  32.     bottle(99);
  33.     return (EXIT_SUCCESS);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment