# New member trying to learn C++, help

I’m a new member. I want to learn programming in C++ so i’ve started and i’ve only gone past the Hello World phase. I’m in a bit of a pinch. I’m trying to loop and from what i understand that looping is just the same code again. What i don’t understand is while (1). Is it like a frame set up?
could anyone please give me any tips on this looping? If i understand i feel that i would understand so much better. Thanks

`The while loop represents the game. Each iteration represents a turn of the game`

This should be the comments on top of the code. Is it not clear?

while(1) is an infinite loop. Its the same as saying while(true).
Generally, when using such a loop you would exit it out of it based on some condition.
However, in this case as thibaugCG mentioned it represents the game, so there is no need to exit out.

Well i can of understand that but now i’m on python3. I read that its a good start for a beginner like me. I’ve managed to do one loop but creating consecutive loops is problematic. Any tips?

What problem are you facing?

The loop challenge. I can’t seem to create another loop in order for the game to run smoothly. I’m working on The Descent puzzle. I passed the first case by list the mountain in order but when going into scattered mountain I can’t seem create another loop.

How does your nested loop look currently

You would do something like this for a nested loop

``````for (int i = 0 ; i < n; ++i)
{
for (int j = 0 ; j < m; ++j)
{
// Your logic here
}
}``````

A nested loop? I only did a simple loop. Could you explain to me how to do a nested loop? Here’s what i have so far for the first loop that i completed.

``````while True:
max = 0
imax = 8
for i in range(8):
mountain_h = int(input())

# Write an action using print
# To debug: print("Debug messages...", file=sys.stderr)

# The index of the mountain to fire on.
print("0")
print("1")
print("2")
print("3")
print("4")
print("5")
print("6")
print("7")
break
while (1):
for i in range(10):
mountain_h = int(input())
print("4")``````

it seems as if your are hardcoding your solution.
You should be having a conditional check of some sort and just 1 print statement

This is still all too confusing to me. I’m sorry, but please explain to me all the terms like hardcoding and a nested loop.

Well i only started recently learning python. Although i’m understand the term i guess i’m just not undertsnading how to use them.

Could I use the list iteration in a loop? Like just shooting down all the mountain in one function that it way I can break it? I don’t think it will make much since i’m hard coding I can’t move on to the next test case since it doesn’t recognize the mountain numbers. I was excited when I completed the first test case. Then the there rose a problem with the other. I tried doing the same thing with the first, but it didn’t seem to even notice it. It just kept crashing into mountain 3. @Speedrun
@TwoSteps

Try not to multi-post please. I replied to you on the other thread. I hope it helps.