Книга: C# 2008 Programmer
Nested for Loop
Nested for Loop
It is common to nest two or more for loops within one another. The following example prints out the times table from 1 to 10:
for (int i = 1; i <= 10; i++) {
Console.WriteLine("Times table for {0}", i);
Console.WriteLine("=================");
for (int j = 1; j <= 10; j++) {
Console.WriteLine ("{0} x {1} = {2}", i, j, i*j);
}
}
Figure 3-11 shows the output.
Figure 3-11
Here, one for
loop is nested within another for
loop. The first pass of the outer loop (represented by i
in this example) triggers the inner loop (represented by j
). The inner loop will execute to completion and then the outer loop will move to the second pass, which triggers the inner loop again. This repeats until the outer loop has finished executing.
- Looping
- for Loop
- foreach
- Forced writes - палка о двух концах
- Forced Writes
- Chapter 15. Graphical User Interfaces for Iptables
- What NAT is used for and basic terms and expressions
- Information request
- SCTP Generic header format
- System tools used for debugging
- FORWARD chain
- How to use this License for your documents