ivanakarpuzova

Испит - прва задача (СО ФУНКЦИЈА)

Jan 22nd, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 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. void soFunkcija(int n) {
  14.     int i;
  15.     while(n != 0){
  16.         for(i = 1; i <= n; i++)
  17.             printf("%d ", i);
  18.  
  19.         for(i = n-1; i > 0; i--)
  20.             printf("%d ", i);
  21.  
  22.         n--;
  23.         printf("\n");
  24.     }
  25. }
  26. int main()
  27. {
  28.     int i, n;
  29.     scanf("%d", &n);
  30.     soFunkcija(n);
  31.     return 0;
  32. }
Add Comment
Please, Sign In to add comment