ivanakarpuzova

Испит - прва задача

Jan 22nd, 2017
163
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. #include <stdlib.h>
  3. /*
  4. Input:
  5. 4
  6. 1
  7. Output:
  8. 1 2 3 4 3 2 1
  9. 1 2 3 2 1
  10. 1 2 1
  11. 1
  12. */
  13. int main()
  14. {
  15.     int i, n;
  16.     scanf("%d", &n);
  17.     while(n != 0){
  18.         for(i = 1; i <= n; i++)
  19.             printf("%d ", i);
  20.  
  21.         for(i = n-1; i > 0; i--)
  22.             printf("%d ", i);
  23.  
  24.         n--;
  25.         printf("\n");
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment