Smart pascal source code
function MyFunc(i : Integer) : Integer;
begin
if i<=0 then
Exit(-1)
else begin
Result:=i;
if i=10 then
Exit(i+1)
else if i>10 then
Exit(Result+2)
end;
end;
function MyFunc2(i : Integer) : Integer;
begin
if i<=0 then
exit -1
else begin
Result:=i;
if i<10 then
exit
else if i=10 then
exit i+1
else if i>10 then
exit Result+2
end;
end;
{------ main.pas ------}
Begin
WriteLn(MyFunc(0));
WriteLn(MyFunc(5));
WriteLn(MyFunc(10));
WriteLn(MyFunc(11));
{ <<< CONSOLE OUTPUTS >>>
-1
5
11
13
}
WriteLn(MyFunc2(0));
WriteLn(MyFunc2(5));
WriteLn(MyFunc2(10));
WriteLn(MyFunc2(11));
{ <<< CONSOLE OUTPUTS >>>
-1
5
11
13
}
WriteLn(MyFunc(0));
WriteLn(MyFunc(5));
WriteLn(MyFunc(10));
WriteLn(MyFunc(11));
WriteLn(MyFunc2(0));
WriteLn(MyFunc2(5));
WriteLn(MyFunc2(10));
WriteLn(MyFunc2(11));
function MyFunc2(i) {
var Result = 0;
if (i<=0) {
return -1;
} else {
Result = i;
if (i<10) {
return Result;
} else if (i==10) {
return i+1;
} else if (i>10) {
return Result+=2;
}
}
return Result
};
function MyFunc(i$1) {
var Result = 0;
if (i$1<=0) {
return -1;
} else {
Result = i$1;
if (i$1==10) {
return i$1+1;
} else if (i$1>10) {
return Result+=2;
}
}
return Result
};