UVa 488 - Triangle Wave

Summary
Generate a wave of a given frequency and amplitude

Explanation
The obscurity of the problems is within the small number of test cases, but given the one given here should make the problem a lot clearer.

Gotchas

 * There is a blank line after each separate waveform, excluding the last one.

Anyway, don't waste time on REPETITION and also I/O. Just simply use a string and store all output for a triangle in it, then simply write it in output for many times! And runtime will be around 0.280 in this method.
 * There is a lot of input data, and this problem became harder after UVa's immigration,


 * If you use C++, use printf and scanf. With cin and cout you will get TLE.
 * Only if you don't know how to use it correctly.

Input
2

3 2 4 3

Output
1 22 333 22 1

1 22 333 22 1

1 22 333 4444 333 22 1

1 22 333 4444 333 22 1

1 22 333 4444 333 22 1

Solutions
C++: http://code.google.com/p/my-solved-problems/source/browse/trunk/Uva/488-Triangle+Wave?r=41