Skip to content

Instantly share code, notes, and snippets.

View phoemur's full-sized avatar

phoemur phoemur

  • Avaré-SP, Brazil
View GitHub Profile
@phoemur
phoemur / minesweeper.cpp
Last active November 8, 2017 01:17
Minesweeper comand line C++
#include <deque>
#include <iostream>
#include <iomanip>
#include <random>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
struct Cell { //represents one cell in the minefield
@phoemur
phoemur / FFT.cpp
Last active August 23, 2023 02:10
Cooley–Tukey Fast Fourier Transform algorithm - Recursive Divide and Conquer implementation in C++
// g++ -o FFT FFT.cpp -Wall -O3
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>
#include <type_traits>
#include <vector>
using namespace std;
@phoemur
phoemur / shunting_yard.cpp
Created March 24, 2018 03:18
Shunting_yard algorithm
/* while there are tokens to be read:
read a token.
if the token is a number, then push it to the output queue.
if the token is an operator, then:
while ((there is an operator at the top of the operator stack with
greater precedence) or (the operator at the top of the operator stack has
equal precedence and
the operator is left associative)) and
(the operator at the top of the stack is not a left bracket):
pop operators from the operator stack, onto the output queue.
@phoemur
phoemur / main.cpp
Created March 25, 2018 16:44
Recursive Descent Parser for arithmetic expressions
// g++ -o parser main.cpp parser.h parser.cpp -O3 -Wall -fpie
#include <iomanip>
#include <iostream>
#include <string>
#include <sstream>
#include "parser.h"
using namespace std;
@phoemur
phoemur / binary_heap.hpp
Created April 3, 2018 18:42
Binary Heap implemented using C++ STL algorithms for heaps
#ifndef BINARY_HEAP_HPP
#define BINARY_HEAP_HPP
#include <algorithm>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <stack>
#include <type_traits>
#include <vector>
@phoemur
phoemur / avltree.hpp
Last active November 30, 2023 02:46
AVL Tree implemented in modern C++ (C++14), using smart_pointers for memory management, move semantics and variadic number of elements for insert and remove
// based on https://users.cs.fiu.edu/~weiss/dsaa_c++4/code/AvlTree.h
#ifndef AVL_TREE_HEADER_MAIN
#define AVL_TREE_HEADER_MAIN
#include <algorithm>
#include <initializer_list>
#include <iostream>
#include <iterator>
#include <memory>
@phoemur
phoemur / tictactoe.cpp
Created April 11, 2018 22:34
Exemplo para o VOL. Compilar com: g++ -o tictactoe tictactoe.cpp
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <utility>
//print instructions
void instructions(const std::array<std::array<char, 3> ,3>& board)
{
std::cout << "Choose a cell numbered from 1 to 9 as below\n and play\n\n";
@phoemur
phoemur / dynbitset.hpp
Created April 27, 2018 01:27
Dynamic Bitset in C++ implemented as a std::vector<bool>
#ifndef DYNAMIC_BITSET_HEADER
#define DYNAMIC_BITSET_HEADER
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <stdexcept>
#include <string>
#include <sstream>
@phoemur
phoemur / CMakeLists.txt
Created May 13, 2018 20:15 — forked from Univan-Ahn/CMakeLists.txt
Moving from QMake to CMake for Qt5 projects
cmake_minimum_required(VERSION 2.8.11)
project(Qt5App)
#
# Qt5 support
#
# general overview:
# * [Modern CMake with Qt and Boost](http://www.kdab.com/modern-cmake-with-qt-and-boost/)
# * [Using CMake with Qt 5](http://www.kdab.com/using-cmake-with-qt-5/)
/*16
1 4
2 4
3 4
4 5
5 6
6 7
7 8
7 9
6 10