August 29, 2011

Example 4

Task:
Make a program  that require input an integer n:
Example:
If n = 3
Output:
1
2
3
2
1

If n = 4
Output:

1
2
3
4
3
2
1


Code:
input n
For a <- 1 to n do a++
{
  print a + newline
}

For a <- n-1 downto 1 do a--
{
  print a + newline
}

No comments:

Post a Comment