Advertisement
What_Ever

Untitled

Dec 20th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. void printSequence(int n);
  3. int max(int a, int b);
  4. int main()
  5. {
  6.     int n;
  7.     printf("please enter an integer:");
  8.     scanf("%d",&n);
  9.     printSequence(n);
  10. }
  11. void printSequence(int n)
  12. {
  13.     static int maxN = 0;
  14.     maxN = max(n,maxN);
  15.     if(n > 0)
  16.     {
  17.         printf("%d ",maxN-n+1);
  18.         printSequence(n-1);
  19.         return;
  20.     }
  21. }
  22. int max(int a , int b)
  23. {
  24.     if(a >= b)
  25.         return a;
  26.     return b;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement