Shouldn't this be resolved with a nested loop? I for one did not have any ideas, for a nested loop, resolved with some help, but with 2 separate "for" loops. Anyone any hints?
Nested?
Under discussion
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Robert Rix
31 December 2019, 21:56useful
(do not count any of the eights in the horizontal line as part of this vertical line)
I think this line here specifically hints about excluding the use of nested loops. A nested solution would be possible, but unnecessarily complicated. Here's a nested solution that seems like it would work
for(int i = 0; i <8; i++){
if (i==1) System.out.println();
for( int j = 0; j <8; j++){
if(i==0) System.out.print("8");
else if (i==1) System.out.println("8");
}
}
+1
Robert Rix
31 December 2019, 21:57
*edit for(int i = 0; i <2; i++){
0
Cz Ferencz
6 December 2019, 18:40
Yes, it only asked to use "for" , not as how. But i guess it would be more witty :d , using a nested one. I just can't figure out how, if there is such a solution to this exercises. Thanks for the feedback anyway. :)
0
Guadalupe Gagnon
6 December 2019, 18:22
How you solve it is up to you. The only requirement is that in must use a for loop. This is not the same as saying that it must only use one for loop.
+1