Skip to content

Instantly share code, notes, and snippets.

#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 / pi.c
Created August 25, 2015 16:17
A memory method to calculate pi
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ARRAY_SIZE 128000
int main(int argc, char **argv)
{
int casas = argc == 2 ? atoi(argv[1]) : 1000;
int x[ARRAY_SIZE];
@bencz
bencz / float_to_ieee754.c
Last active November 30, 2015 18:09
Programa para converter float para o padrão ieee754 (binario)
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#if __USE_SSE__
void reverse(char *begin, char *end)
{
_asm
{
mov edx, DWORD PTR[begin]
@bencz
bencz / main.cs
Created June 5, 2015 20:12
bmp generator ( test )
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace bmpGenerator
{
public class ColorX
{
#define system.
#define extensions.
#class MyNumber
{
#field theValue.
#constructor new : aValue
[
theValue := aValue.
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stdlib.h>
using namespace std;
typedef struct _SIZE_
{
@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)
{
@bencz
bencz / main.d
Last active August 29, 2015 14:03
ExeMaker_DLanguae
// A big special thanks to 'bearophile' ( from dlang forum! )
import std.c.windows.windows: WORD, LONG, DWORD, BYTE, UCHAR, ULONG;
struct IMAGE_DOS_HEADER
{
WORD e_magic,
e_cblp,
e_cp,
e_crlc,
@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')