Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

i

f(i)

1

12

2

12

3

11

Other values

0

Compliant

...

Solution

The compliant example solution separates the switch and for blocks:

...

Many people . . . have said that the worst feature of C is that switches don't break automatically before each case label. This code forms some sort of argument in that debate, but I'm not sure whether it's for or against.

Compliant

...

Solution (Duff's Device)

This is an alternative implementation of Duff's device, which separates the switch statement and loop:

...