Nested Loop / Loop Tutorial

I am looking for a good tutorial on writing and constructing loops. I understand the basics of loops, but nested loops give me a ton of problems. To give you an idea, the following figure below was difficult for me to understand.

1
12
123
1234
12345
123456

+5
source share
7 answers

Loops

A cycle is a design that allows you to execute several commands several times. There are several circuit designs:

zero or more

These loops have a check at the start of the iteration and as such will be executed 0 or more times. An example of a while loop.

one or more

. do while while.

, . (, ).

.

. , , , .

, . . :

1
12
123
1234
12345
123456

, .

  • 1
  • 1 2
  • 1 3
  • ...

: n- 1 n.

, . .

  • n = 1
  • n = 2
  • n = 3
  • ...

Hm, n :

for n = 1 to 6
  s = ''
  for i = 1 to n // use the loopcounter of the outer loop
    s = s + char(i)
  end for
  out s
end for
+7
+1

, - " " , . , . , , ...

0

- , Google. , , , , , , . , . /, , . , !

0

MIT Course. Safari, .

MIT python.

I found that working on this on paper, listing variables helps in learning how this works.

0
source
declare
s varchar2(10);
begin
  for n in 1..5 loop
    s:='';
    for i in 1..n loop
      s:=s||(i);
    end loop;
    dbms_output.put_line(s);
  end loop;
end;
0
source

All Articles