ivanakarpuzova

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

Jan 22nd, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 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. if(i != n) {
  20. printf("%d ", 1);
  21. continue;
  22. }
  23. else {
  24. printf("%d ", n);
  25. }
  26. }
  27.  
  28. for(i = n-1; i > 0; i--){
  29. if(i != n) {
  30. printf("%d ", 1);
  31. continue;
  32. }
  33. else {
  34. printf("%d ", n);
  35. }
  36. }
  37.  
  38. n--;
  39. printf("\n");
  40. }
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment