Thursday 15 August 2013

c++ - Trying to display a numbered grid, stuck in an infinite loop -


I am very new to C ++, and to get a line of input and print it on the screen Also to programming (I'm working with Alex Allen's jump from C ++.) I'm trying to print a simple 3x3 grid, with the number of each class (Takatako board.), But in 1 infinite loop stuck around. I'm sure this problem is incredibly simple and possibly reading it is obvious to everyone, but I can not see it

This is my code, and thanks in advance for your help:

  int main () (for int i = 1; i <10; i + +) {Cout & lt; & Lt; "_____________ \ n"; While (i & lt; = 3) {cout & lt; & Lt; "|" & Lt; & Lt; I & lt; & Lt; ";"; } Cout & lt; & Lt; "\ N"; Cout & lt; & Lt; "| --- | --- | --- | \ n"; While (i> 3 & amp; amp; i & lt; = 6) {cout & lt; & Lt; "|" & Lt; & Lt; I & lt; & Lt; "."; } Cout & lt; & Lt; "/ N"; Cout & lt; & Lt; "| --- | --- | --- | \ n"; While (i> 6 & amp; amp; & amp; lt; = 9) {cout & lt; & Lt; "|" & Lt; & Lt; I & lt; & Lt; "."; } Cout & lt; & Lt; "| | ___ | ___ | ___ | \ n"; Cout & lt; & Lt; "\ N"; First} you have an external loop  
        

    

However when you will be i for the first time on that internal loop, then 1 , and it will never change in the inner loop expression i will always be always , and so you have an infinite loop.

No comments:

Post a Comment