Selezioni

Algoritmo Traduzione in Pascal Le etichette Begin End sono facoltative quando si controllano singole istruzioni ma…
if
Writeln('0');

If E = 1 Then
   Begin
      Writeln('-11-');
      Writeln('-12-');
   End;

Writeln('2');
Writeln('0');

If E = 1 Then
   Writeln('-1-');

Writeln('2');
if2
Writeln('0');

If E = 1 Then
   Begin
      Writeln('-11-');
      Writeln('-12-');
   End
Else
   Begin
      Writeln('-21-');
      Writeln('-22-');
   End;

Writeln('3');
Writeln('0');

If E = 1 Then
   Writeln('-1-')
Else
   Writeln('-2-');

Writeln('3');
if32
Writeln('0');

If E = 1 Then
   Begin
      Writeln('-11-');
      Writeln('-12-');
   End
Else If E = 2 Then
   Begin
      Writeln('-21-');
      Writeln('-22-');
   End
Else
   Begin
      Writeln('-31-');
      Writeln('-32-');
   End;

Writeln('4');
Writeln('0');

If E = 1 Then
   Writeln('-1-')
Else If E = 2 Then
   Writeln('-2-')
Else
   Writeln('-3-');

Writeln('4');
if3n
Writeln('0');

If E = 1 Then
   Begin
      Writeln('-11-');
      Writeln('-12-');
   End
Else If E = 2 Then
   Begin
      Writeln('-21-');
      Writeln('-22-');
   End
...
...
Else
   Begin
      Writeln('-n1-');
      Writeln('-n2-');
   End;

Writeln('n+1');
Writeln('0');

If E = 1 Then
   Writeln('-1-')
Else If E = 2 Then
   Writeln('-2-')
...
...
Else
   Writeln('-n-');

Writeln('n+1');
if322
Writeln('0');

If E = 1 Then
   Begin
      Writeln('-11-');
      Writeln('-12-');
   End
Else If E = 2 Then
   Begin
      Writeln('-21-');
      Writeln('-22-');
   End;

Writeln('3');
Writeln('0');

If E = 1 Then
   Writeln('-1-')
Else If E = 2 Then
   Writeln('-2-');

Writeln('3');
if3n2
Writeln('0');

If E = 1 Then
   Begin
      Writeln('-11-');
      Writeln('-12-');
   End
Else If E = 2 Then
   Begin
      Writeln('-21-');
      Writeln('-22-');
   End
...
...
Else If E = n Then
   Begin
      Writeln('-n1-');
      Writeln('-n2-');
   End;

Writeln('n+1');
Writeln('0');

If E = 1 Then
   Writeln('-1-')
Else If E = 2 Then
   Writeln('-2-')
...
...
Else If E = n Then
   Writeln('-n-');

Writeln('n+1');
if4
Writeln('0');

If A > 0 Then
   If B > 0 Then
      Begin
         Writeln('-11-');
         Writeln('-12-');
      End
   Else
      Begin
         Writeln('-21-');
         Writeln('-22-');
      End
Else
   If C > 0 Then
      Begin
         Writeln('-31-');
         Writeln('-32-');
      End
   Else
      Begin
         Writeln('-41-');
         Writeln('-42-');
      End;

Writeln('5');
Writeln('0');

If A > 0 Then
   If B > 0 Then
      Writeln('-1-')
   Else
      Writeln('-2-')
Else
   If C > 0 Then
      Writeln('-3-')
   Else
      Writeln('-4-');

Writeln('5');
ifcio1
Writeln('0');

If A > 0 Then
   If B > 0 Then
      Begin
         Writeln('-11-');
         Writeln('-12-');
      End
   Else
      Begin
         Writeln('-21-');
         Writeln('-22-');
      End;

Writeln('3');
Writeln('0');

If A > 0 Then
   If B > 0 Then
      Writeln('-1-')
   Else
      Writeln('-2-');

Writeln('3');
ifcio2
Writeln('0');

If A > 0 Then
   Begin
      If B > 0 Then
         Begin
            Writeln('-11-');
            Writeln('-12-');
         End
   End
Else
   Begin
      Writeln('-21-');
      Writeln('-22-');
   End;

Writeln('3');
Writeln('0');

If A > 0 Then
   Begin
      If B > 0 Then
         Writeln('-1-');
   End
Else
   Writeln('-2-');

Writeln('3');

Eliminare le etichette Begin End nell’ultimo caso sarebbe un errore!
Il codice diventerebbe identico a quello del diagramma di flusso precedente…