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
| /* | |
| INPUT SAMPLE: | |
| VAR NUMBER = 25 | |
| VAR STRING = "ALEX" | |
| VAR ERRO = "THAT's NOT CAUSE AN ERROR :)" | |
| PRINT ERRO | |
| PRINT "ALEXANDRE" | |
| PRINT NUMBER |
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
| #include <cstdio> | |
| #include <vector> | |
| #include <windows.h> | |
| using namespace std; | |
| class Buffer: public vector<unsigned char> | |
| { | |
| public: | |
| void push_dword(DWORD dw) |
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
| var ref = require("ref"); | |
| var ffi = require("ffi"); | |
| var libc = ffi.Library("libc", { | |
| "mmap": ["pointer", ["pointer", "size_t", "int", "int", "int", "int64"]], | |
| "munmap": ["int", ["pointer", "size_t"]], | |
| }); | |
| var PROT_READ = 1; | |
| var PROT_WRITE = 2; |
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
| var fs = require("fs"); | |
| function convLE(len, v) { | |
| var ret = ""; | |
| for (var i = 0; i < len; ++i) { | |
| ret += String.fromCharCode(v & 0xff); | |
| v >>= 8; | |
| } | |
| return ret; | |
| } |
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
| void inc(int &x) { | |
| ++x; | |
| } | |
| void inc(int *x) { | |
| ++*x; | |
| } |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| struct A{ | |
| char s[10000]; | |
| A() { | |
| strcpy(s, "123"); | |
| } |
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
| sealed trait Expr | |
| case class N(n: Int) extends Expr | |
| case class Add(n: Expr*) extends Expr | |
| case class Mul(n: Expr*) extends Expr | |
| def str(e: Expr): String = e match { | |
| case N(x) => x.toString | |
| case Add() => "" | |
| case Add(x) => str(x) | |
| case Add(x, xs@_*) => str(x) ++ "+" ++ str(Add(xs: _*)) |
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
| sealed trait Expr | |
| case class N(n: Int) extends Expr | |
| case class Var(x: String, a: Int, n: Int) extends Expr | |
| case class Add(n: Expr*) extends Expr | |
| case class Mul(n: Expr*) extends Expr | |
| def add(xs: List[Expr]): Expr = xs match { | |
| case List() => N(0) | |
| case List(x) => x | |
| case _ => Add(xs.toArray: _*) // Add(WrappedArray(N(1), N(2), Var(x,2,2))) |
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
| sealed trait Expr | |
| case class N(n: Int) extends Expr | |
| case class Var(x: String, a: Int, n: Int) extends Expr | |
| case class Add(n: Expr*) extends Expr | |
| case class Mul(n: Expr*) extends Expr | |
| def x(a: Int, n: Int): Var = { | |
| Var("x", a, n) | |
| } |
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
| import scala.language.implicitConversions | |
| // R is derived from Rational with some fixes. | |
| // https://sites.google.com/site/scalajp/home/documentation/scala-by-example/chapter6 | |
| case class R(n: Int, d: Int) extends Ordered[R] { | |
| private def gcd(x: Int, y: Int): Int = { | |
| if (x == 0) y | |
| else if (x < 0) gcd(-x, y) | |
| else if (y < 0) -gcd( x, -y) |
OlderNewer