Created
January 19, 2018 19:10
-
-
Save yunyu/98845188faa076406adff9d7b438e735 to your computer and use it in GitHub Desktop.
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
let | |
type any = {any : int} | |
var buffer := " " | |
function readint() : int = | |
let var i := 0 | |
var any := any{any=0} | |
function isdigit(s : string) : int = | |
ord(buffer)>=ord("0") & ord(buffer)<=ord("9") | |
function skipto() = | |
while buffer=" " | buffer="\n" | |
do buffer := getchar() | |
in skipto(); | |
any.any := isdigit(buffer); | |
while isdigit(buffer) | |
do (i := i*10+ord(buffer)-ord("0"); buffer := getchar()); | |
i | |
end | |
function printint(i: int) = | |
let function f(i:int) = if i>0 | |
then (f(i/10); print(chr(i-i/10*10+ord("0")))) | |
in if i<0 then (print("-"); f(-i)) | |
else if i>0 then f(i) | |
else print("0") | |
end | |
in | |
/* Your code here */ | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment