Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar
💭
If I have seen further it is only by standing on the shoulders of giants. Newton

Adrian Statescu thinkphp

💭
If I have seen further it is only by standing on the shoulders of giants. Newton
View GitHub Profile
@thinkphp
thinkphp / perianderOfCorinth.c
Created February 4, 2018 16:22
combSort using pointer to function for fun.
#include <stdio.h>
#include <malloc.h>
#define FIN "algsort.in"
#define FOUT "algsort.out"
//pointer to function
typedef void (*fnPtr)(int*,int);
void combsort(int *p, int n) {
@thinkphp
thinkphp / erathostenes.cpp
Created December 31, 2017 08:08
Sieve of Erathostenes
#include <iostream>
#include <fstream>
typedef unsigned long ulong;
typedef unsigned int uint;
namespace Erathostenes {
ulong getCount(ulong n) {
@thinkphp
thinkphp / subsets.cpp
Created December 28, 2017 08:30
Generating the subsets of a set.
#include <iostream>
#include <fstream>
#include <vector>
#define FIN "submultimi.in"
#define FOUT "submultimi.out"
using namespace std;
int main() {
@thinkphp
thinkphp / belongPointCircle.c
Created October 18, 2017 08:13
Belonging to a point to circles implemented in C Language
/**
* Adrian Statescu <http://adrianstatescu.com>
* Input -> n circle and one Point
* Output -> belong or not on disk.
*/
#include <stdio.h>
#include <math.h>
#define SIZE 50
typedef struct TypePoint {
@thinkphp
thinkphp / SinglyLinkedList.c
Created October 10, 2017 08:32
Demystifying the Singly Linked List for C Developers.
/**
* Adrian Statescu <http://adrianstatescu.com> - <mergesortv@gmail.com> - <http://thinkphp.ro>
*
* Demystifying the Singly Linked List for C Developers.
*
* - create
* - display
* - reverse
* - addBefore
* - addAfter
@thinkphp
thinkphp / EuclidArray.rb
Created October 8, 2017 09:52
Finding Euclid for an array in Ruby
#
# Adrian Statescu <mergesortv@gmail.com>
#
# Euclid's Algorithm implemented in Ruby language for an array of integers
#
# Find using - Divide et Impera
# - Recursion
require 'test/unit'
@thinkphp
thinkphp / polymorphism.rb
Last active October 6, 2017 04:10
Perm and Queen in Ruby using the concept the OOP Polymorphism
#
# Adrian Statescu <mergesortv@gmail.com>
# Object-oriented Programming Concept Polymorphism.
# A class enherits states and behavior from its superclass. Inheritance provides a powerful and natural mechanism for
# organizing and structuring software program.
# Polymorphism is ability to appear in many forms and it is to redefine methods for derivated classes.
# The languages's ability to process objects differently depending on their datatype and class
class Bkt
@thinkphp
thinkphp / insert_sort_linked_list.cpp
Created September 28, 2017 02:15
Insert Sort using Linked List in c++
#include <iostream>
#define MAXINT 32000
using namespace std;
struct Node {
int info;
struct Node *next;
};
@thinkphp
thinkphp / ptrToMatrix.cpp
Created September 24, 2017 08:08
Pointers to Matrix in C++. int (*mat)[10]
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void *readMatrix(int l,int c) {
srand (time(NULL));
@thinkphp
thinkphp / golden-ratio.c
Created September 19, 2017 06:36
Golden Ratio in C lang
#include <stdio.h>
#include <math.h>
float golden_ration_root_iteration(float phi, float EPS) {
float tmp = 0.0;
phi = 1.0;
EPS = 1E-8;