Skip to content

Instantly share code, notes, and snippets.

@bencz
bencz / determinante.c
Created March 17, 2013 09:13
Programa para calcular o determinante de uma matriz NxN
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int m = 0;
double **a = 0;
int i = 0, j = 0, k = 0;
double factor = 0;
double temp = 0;
@bencz
bencz / main.cpp
Created November 20, 2012 05:40
Basic compiler, generate IL CODE
/*
INPUT SAMPLE:
VAR NUMBER = 25
VAR STRING = "ALEX"
VAR ERRO = "THAT's NOT CAUSE AN ERROR :)"
PRINT ERRO
PRINT "ALEXANDRE"
PRINT NUMBER
@bencz
bencz / main.c
Last active August 18, 2021 18:22
Tipo pró!
#include <stdio.h>
#if _MSC_VER
#define ASMDEF __asm
#elif __ORANGEC__ || __DMC__
#define ASMDEF asm
#endif
int xor(int a, int b)
{
#include <stdio.h>
int m = 1811939329, N = 1, t[1 << 26] = { 2 }, a, *p, i, e = 73421233, s, c, U = 1;
void g(int d, int h)
{
for (i = s; i < 1 << 25; i *= 2)
d = d * 1LL * d % m;
for (p = t; p < t + N; p += s)
for (i = s, c = 1; i; i--)
@bencz
bencz / main.cs
Last active December 28, 2015 15:29
Calculate the SEN of X and COSSINE of X and, calculate PI
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace seno
{
@bencz
bencz / main.c
Created November 17, 2013 18:16
read a line in C
#include <stdio.h>
#include <string.h>
int fgetline(FILE *fp, char s[], int lim)
{
char *t;
int c, len=lim;
t = s;
while (--lim>1 && (c=getc(fp)) != EOF && c != '\n')
@bencz
bencz / main.fs
Created June 15, 2013 15:23
bf interpreter
open System
open System.IO
open System.Collections.Generic
let args = Environment.GetCommandLineArgs()
if args.Length <> 2 then Environment.Exit(1)
let bf = File.ReadAllText(args.[1])
let loop = Array.zeroCreate<int>(bf.Length)
let stack = Stack<int>()
@bencz
bencz / gr.asm
Last active December 17, 2015 13:49
Calculate the gold number in Assembly :)
.extern _putchar
.extern _getchar
.globl _main
.data
bfs:
.zero 262144
.text
_main:
@bencz
bencz / gr.c
Created April 30, 2013 13:31
Program to calculate the Golden ratio with infinite decimal places of precision... :)
/*
1.61803398874989484820458683436563811772030917980576286213544862270526046281890
2449707207204189391137484754088075386891752126633862223536931793180060766726354
4333890865959395829056383226613199282902678806752087668925017116962070322210432
1626954862629631361443814975870122034080588795445474924618569536486444924104432
0771344947049565846788509874339442212544877066478091588460749988712400765217057
5179788341662562494075890697040002812104276217711177780531531714101170466659914
6697987317613560067087480710131795236894275219484353056783002287856997829778347
8458782289110976250030269615617002504643382437764861028383126833037242926752631
@bencz
bencz / AST.h
Last active December 15, 2015 00:39
A test of compiler
using namespace System;
/* <stmt> := var <ident> = <expr>
| <ident> = <expr>
| for <ident> = <expr> to <expr> do <stmt> end
| read_int <ident>
| print <expr>
| <stmt> ; <stmt>
*/
public ref class Stmt abstract