Solved

a forloop inside a forloop - need help with logic

Posted on 2009-12-30
150 Views
I have 2 arrays with size of 100. These arrays have elements inside them.

Lets say i have array1 and array2. I want something as follows ;

array1[1] then enters forloop and checks 1-50of array 2.
array1 goes to [2] and checks 1-50
and so on.

if i do just the basic a forloop inside a forloop for example ..

for(int i = 0; i<50; i++){
for(int i = 0; i<50; i++){
}
}

Would that work?
0
Question by:rinengan

LVL 92

Expert Comment

for(int i = 0; i<50; i++){
for(int j = 0; j<50; j++){
}
}
0

LVL 6

Expert Comment

Yes, that would work - the inner loop would be repeated for each pass through the outer loop.
0

LVL 40

Accepted Solution

i think he is looking for

for(int i = 0; i<100; i++)
{
for(int j = 0; j<50; j++)
{
}
}

since he is looking for 50 elements only in the second array not the first one.

0

Author Comment

thanks alot guys, i just wanted 2 check with u if its alright :]
0

Featured Post

Suggested Solutions

sameEnds challenge 25 55
canBalance challenge 34 54
array6 challenfge 6 48
@SBGen Method 3 14
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.