Created
November 10, 2015 02:34
-
-
Save freeonterminate/f7a9180681cd40436487 to your computer and use it in GitHub Desktop.
[tips] C like case-sentence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program CLikeSwitchCase; | |
function SwitchCase(const A: Integer): Integer; | |
label | |
Case0, Case1, CaseElse; | |
begin | |
Result := 0; | |
case A of | |
0: goto Case0; | |
1: goto Case1; | |
else goto CaseElse; | |
end; | |
Case0: | |
Inc(Result); | |
Case1: | |
Inc(Result); | |
CaseElse: | |
Inc(Result); | |
end; | |
begin | |
Writeln(SwitchCase(0)); // 3 | |
Writeln(SwitchCase(1)); // 2 | |
Writeln(SwitchCase(2)); // 1 | |
Readln; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment