1. The outer loop is judged by the loop condition, which satisfies the outer circulation body and executes externally.
2. The inner layer to determine the cycle conditions, to meet the internal circulation body
3. Internal Loop execution
4. The inner loop variable accumulates, returns to 2 executes, until does not satisfy 2
5. The outer loop variable accumulates until the condition is not met and exits the loop completely
Print multiplication table: for (int i=1,i<=9,i++)
{
for (int j=1,j<=i,j++)//j<=i;
{Console.Write ("{0}*{1}={2}", i,j,i*j);
}
Console.WriteLine ();
}
1. First assign the value i = 1, then judge I <=9, satisfy the condition, enter the outer loop body
2. Assign a value j=1, Judge J<=i, (at this point two values are the same), into the inner loop, output 1*1=1
3. Internal Loop J Variable accumulation j=2 does not meet j<=2, execution console. Wriet () outputs a line break symbol
4. External loop variable accumulation i=2, satisfies execution j=1, satisfies, executes j=2, satisfies, executes j=3, does not satisfy, outputs a newline
6, repeat 3~6,i = 3 o'clock, print 3*1=33*2=6,i=4, print 4*1=44*2=84*3=12, when i=9 the last loop, 9*1=9....9*8=72, then accumulate i = 10, do not meet the outer loop, completely exit
Two nested for loop execution order