Quote (carteblanche @ Sep 17 2014 04:55pm)
what is the problem you're facing?
this is how i'd approach the problem:
1) given n, figure out how to write out 1, 2, ..., n - 1, n
eg: given 4, write out 1234
2) given n, figure out how to write out 1, 2, ..., n -1, n, n - 1, .... 2, 1
eg: given 4, write out 1234321
3) given n, figure out how to write out 1, 2, ..., n -1, n, n - 1, .... 2, 1 and then put a new line at the end
eg: given 4, write out 1234321\n
4) assuming the above is done, loop it from 2 to n
do it in this order. don't try to set up all the loops at once, and everything is wrecked. you want to be able to show progress at each step so you can understand it and narrow down where the problem is
this NEEDS to be written in 3 for-loops
and cannot use any other variables than ones declared and initialized within the for-loops
so, I would guess this would have to compare the variable in the 2nd for-loop to the variable in the first for-loop in some way in order to print the first number, then any following on each line
then compare the variable in the third to the second or first
this is where I am sort of lost
If I was able to, I would just use print statements with extra variables, id simply assign new variables and print them: var1 = 1, var2 = 2, var3 = 3, etc.
This post was edited by DD_Rocking on Sep 17 2014 04:08pm