Skip to content

Instantly share code, notes, and snippets.

View olegon's full-sized avatar

Leandro Gonçalves de Oliveira olegon

View GitHub Profile
@olegon
olegon / NotasDaTurma.java
Last active April 11, 2017 18:23
FATEC-SP / POO / Profª Grace/ Classe NotasDaTurma / Leandro Gonçalves de Oliveira / RA 15200213
import java.util.*;
public class NotasDaTurma {
public static void main(String[] args) {
final int ALUNOS = 3;
final int PROVAS = 2;
Scanner scanner = new Scanner(System.in);
double notas[][] = new double[ALUNOS][PROVAS];
@olegon
olegon / mergesort.js
Created April 4, 2017 13:19
nodejs mergesort module
module.exports = mergesort;
function mergesort (array) {
const cp = Array.from(array);
sort(array, 0, array.length - 1, cp);
}
function sort (array, left, right, cp) {
const size = right - left + 1;
@olegon
olegon / quicksort.js
Last active April 4, 2017 12:36
nodejs quicksort module
module.exports = quicksort;
function quicksort (array) {
sort(array, 0, array.length - 1);
}
function sort (array, left, right) {
const size = right - left + 1;
if (size > 1) {
@olegon
olegon / btree_expression.c
Created March 30, 2017 14:21
Avaliação de expressão matemática representada por uma árvore binária.
#include <stdio.h>
#include <stdlib.h>
typedef char BTREE_TYPE;
typedef struct btree {
struct btree *left;
BTREE_TYPE value;
struct btree *right;
} *BTREE;
@olegon
olegon / BST.c
Created March 30, 2017 14:05
Implementação de um BST (Binary Search Tree) | Material: Estruturas de dados em C, Silvio do Lago Pereira
#include <stdio.h>
#include <stdlib.h>
typedef int BST_TYPE;
typedef struct bst {
struct bst *left;
BST_TYPE value;
struct bst *right;
} *BST;
@olegon
olegon / ContaCorrenteTest.java
Created March 28, 2017 15:33
FATEC-SP / POO / Profª Grace/ Classe ContaCorrente / Leandro Gonçalves de Oliveira / RA 15200213
import java.util.*;
public class ContaCorrenteTest {
public static void main(String[] args) {
test1();
System.out.println("----- **");
test2();
System.out.println("----- **");
test3();
System.out.println("----- **");
@olegon
olegon / Data.java
Last active March 30, 2017 14:06
FATEC-SP / POO / Profª Grace/ Classe Data / Leandro Gonçalves de Oliveira / RA 15200213
public class Data {
private int ano;
private int mes;
private int dia;
public Data(int ano) {
atribuirData(ano, 1, 1);
}
public Data(int ano, int mes) {
@olegon
olegon / SS 7-2.cpp
Created March 17, 2017 20:04
Silvio Lago, Ex 7-2
#include <iostream>
#include <cstdlib>
using namespace std;
void enumere(const char *map[], int n, const int *dom[], int m);
void enumere(int i, int *v, const char *map[], int n, const int *dom[], int m);
int main (void) {
const char *map[] = {
@olegon
olegon / SS 7-1.cpp
Created March 17, 2017 19:56
Silvio Lago, Ex. 7-1
#include <iostream>
#include <cstdlib>
using namespace std;
void enumere(const char *map[], int n, const int *dom[], int m);
void enumere(int i, int *v, const char *map[], int n, const int *dom[], int m);
int main (void) {
const char *map[] = {
@olegon
olegon / crivo.js
Created March 17, 2017 18:32
Implementação JavaScript do Crivo de Eratóstenes
function crivo(n) {
const primos = [];
for (let i = 0; i <= n; i++) primos[i] = true;
primos[0] = primos[1] = false;
let limit = ~~Math.sqrt(n);
for (let i = 2; i <= limit; i++) {