fork download
  1. #include <iostream>
  2.  
  3. int main() {
  4. int N;
  5. std::cin >> N;
  6.  
  7. // Print sequence from 1 to N
  8. for (int i = 1; i <= N; ++i) {
  9. std::cout << i << ' ';
  10. }
  11. std::cout << std::endl;
  12.  
  13. // Print sequence from N to 1
  14. for (int i = N; i >= 1; --i) {
  15. std::cout << i << ' ';
  16. }
  17. std::cout << std::endl;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5284KB
stdin
9
stdout
1 2 3 4 5 6 7 8 9 
9 8 7 6 5 4 3 2 1