Whenever you have an issue with the logic of your code please try to post a working example.
is this code even working? This loop for(int i=n; i<=1; i--) will execute for value of n = 0 or 1 only and once inside, you are practically in for infinite loop because i-- will make the value of i to 0 then negative, then i<=1 will remain true. For any value of n > 1, the loop is not going to execute
Assuming you are inside the loop, then the exit condition of inner for loop for(int j=1; i>=n; j++) is controlled by the variable of outer for loop and this loop will execute at the most if n = 0 or 1, after that i value will be less than n
Third for loop will only execute if n=1, and will execute only once.
After that you are in practically infinte loop due to outermost for loop.
Figure out properly what you want to do, how you want to control your loops.
The purpose of code is not clear. what are you trying to achieve? why do you need 3 for loops for 1D array. Wirhout knowing that it's no point trying to optimize it. And if possible share the full code. I can give a shot, but there is no guarantee i'll do better.