Skip to content

Instantly share code, notes, and snippets.

View olegon's full-sized avatar

Leandro Gonçalves de Oliveira olegon

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#define SIZE 1000000
typedef struct item {
int entrada,
saida;
} ITEM;
#include <stdio.h>
#include <stdlib.h>
typedef char STACK_TYPE;
typedef struct {
int index;
int capacity;
STACK_TYPE *values;
} STACK;
@olegon
olegon / infix-postfix.js
Created September 1, 2016 18:19
Esse programa foi feito para transformar expressões da notação infixa para a pós-fixada (polonesa inversa) e vice-versa.
"use strict";
/*
Esse programa foi feito para transformar expressões da notação infixa para a pós-fixada (polonesa inversa) e vice-versa.
*/
function infixToPosfix (infixExpression) {
const postfixExpression = []
@olegon
olegon / I.c
Last active September 14, 2016 12:46
/*
Maratona de Programação da SBC - ACM ICPC - 2016
Problema I
*/
#include <stdio.h>
#include <stdlib.h>
#define TAMANHO_MAXIMO 50000
@olegon
olegon / pilha.pas
Last active September 15, 2016 01:55
{
São Paulo, 14 de setembro de 2016.
FATEC-SP
Pilhas em Pascal
}
program prog_pilha;
#include <stdio.h>
#include <string.h>
void insertion_ints(int v[], int n);
void insertion_chars(char v[], int n);
void insertion_strings(char* v[], int n);
int main (void) {
int i;
@olegon
olegon / PriorityQueue.js
Created January 13, 2017 17:02
Implementação de PriorityQueue com Binary Heap, JavaScript ES6
/*
Implementação de PriorityQueue com Binary Heap.
JavaScript ES6
*/
class PrioriryQueue {
constructor (cmp = (a, b) => a > b) {
this.array = [null];
this.cmp = cmp;
}
@olegon
olegon / quicksort.js
Created January 13, 2017 19:23
Quicksort Algorithm
/*
Quicksort Algorithm
*/
function quicksort(array) {
function partition(a, start, end) {
let i = start,
j = end + 1;
while (true) {
#include <stdio.h>
void minmax(int *v, int n, int *min, int *max);
int main (void) {
int v[5] = { -1, 7, -3, 11, 4 };
int min, max;
minmax(v, 5, &min, &max);
#include <stdio.h>
int sum_positives (int *v, int n);
int main (void) {
int v[5] = { -1, 7, -3, 11, 4 };
int result = sum_positives(v, 5);
printf("Sum: %d\n", result);