Delphi VS C ++ of Syntax (3) loop structure

zhaozj2021-02-16  77

1, while statement

C :

While (expression) {...}.

Delphi:

While Do [] ;. When there are multiple statements in the circulation body, use Begin ... END;

2, DO ... while () statement

C :

Do {...} while ();

Delphi:

REPEAT [] Until . When there are multiple statements in the cyclic body, it can be packed without Begin ... END;

3, for statement

C :

For (;;;) {...}

example:

INT i = 1; for (i; i <5; i ) // or for (i = 2; i <5; i ) {...}

Delphi:

FOR = {To | DOWNTO} DO [];

example:

Var i: integer; i: = 1; for i: = 2 to 5 do // cannot be written as for i to 5 do, because Delphi specifies the for statement counter (i) must be assigned here! Begin ... End; for i: = 2 DOWNTO 0 DO / / counter is decremented. Begin ... End; 4, the same point:

The same point in the above three cycles is that Break can be used in the cycle, and the consisher.break means that the forcibly terminated loop jump out of the cyclic body, Continue means that the cycle in the cycle is ended, and the new one is implemented. Wheel cycle.

转载请注明原文地址:https://www.9cbs.com/read-16066.html

New Post(0)