#C11375. Zigzag Sequence Generation
Zigzag Sequence Generation
Zigzag Sequence Generation
Given a positive integer ( n ), generate the first ( n ) terms of the Zigzag sequence. The sequence is defined as follows:
(a_1 = 1)
For ( i \geq 2 ), if ( i ) is even then ( a_i = a_{i-1} - 1 ), and if ( i ) is odd then ( a_i = a_{i-1} + 2 ).
For example, if ( n = 5 ), then the sequence is: 1 0 2 1 3.
inputFormat
A single integer ( n ) representing the number of terms to generate. The input is provided via standard input (stdin).
outputFormat
Print the first ( n ) terms of the Zigzag sequence separated by a single space on one line. The output should be printed to standard output (stdout).## sample
1
1