Skip to content

Instantly share code, notes, and snippets.

View zaccone's full-sized avatar
💾
Focusing

Marek Denis zaccone

💾
Focusing
View GitHub Profile
int hash(const int x, const int y)
{
int hash = 17;
hash = ((hash + x) << 5) - (hash + x);
hash = ((hash + y) << 5) - (hash + y);
return hash;
}
#include <stdio.h>
#include <string.h>
static const size_t LETTERS = 26;
void permutations(char *str, size_t idx, size_t size, char *letters)
{
if (idx == size) {
printf("%s\n", str);
return;
}
@zaccone
zaccone / stack.c
Created September 5, 2016 18:11
Generic stack in ANSI C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct stack {
size_t capacity;
size_t size;
size_t pos;
size_t us;
void *container;
} stack;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
size_t size;
scanf("%lu", &size);
int *arr = (int *)malloc(size * sizeof(int));
memset(arr, 0, sizeof(arr));
for (unsigned long i = 0; i < size; i++) {