Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
@thinkphp
thinkphp / complex.c
Created December 26, 2019 20:06
Complex Number a+ib
#include <stdio.h>
#define FIN "complex.in"
#define FOUT "complex.out"
struct TComplex {
int real,
imag;
};
typedef struct TComplex Complex;
@thinkphp
thinkphp / sieve_of_Eratosthenes.cpp
Created December 26, 2019 16:46
Sieve of Eratosthenes
/**
*
* Eratosthenes of Cyrene.
*
*/
#include <iostream>
#include <cstdlib>
using namespace std;
@thinkphp
thinkphp / eratosthenes.cpp
Created December 25, 2019 22:14
Eratosthenes
/**
*
* Eratosthenes of Cyrene.
*
*/
#include <iostream>
#include <cstdlib>
using namespace std;
@thinkphp
thinkphp / Byte_swapping.c
Last active December 25, 2019 10:08
Byte Swapping
/*
* Author: Adrian Statescu <mergesortv@gmail.com>
* Description: Byte Swapping.
*/
#include <stdio.h>
void __byteswapping__(void *x1, void *x2, size_t size) {
char *x = (char*)x1;
@thinkphp
thinkphp / combosort.rb
Created December 23, 2019 18:33
Combo Sort Algorithm in Ruby
def comb_sort( list )
shrinkFactor = 1.3
swapped = true
n, gap = list.size, list.size
until (gap == 1) && !swapped
@thinkphp
thinkphp / coliban.c
Created December 16, 2019 21:40
add elements of array using the technique Divide Et Impera.
#include <stdio.h>
#include <malloc.h>
#define FIN "coliban.in"
int euclid(int a, int b) {
if(b == 0) return a;
else return euclid(b, a % b);
}
@thinkphp
thinkphp / sycorax.c
Created December 16, 2019 06:58
Give a N = and removes all primes digits from this number using linked simple list.
#include <stdio.h>
#include <malloc.h>
struct Node {
int info;
struct Node *next;
};
typedef struct Node Node;
/*
* Test if a number is Prime or not.
*/
#include <stdio.h>
int isPrime(int n) {
if(n == 0 || n == 1) return 0;
if(n == 2 || n == 3) return 1;
@thinkphp
thinkphp / queue.c
Created December 11, 2019 19:33
Queue Data Structure
#include <stdio.h>
#define Q_MAX 10
struct Queue {
int queue[Q_MAX];
int rear,
front;
};
@thinkphp
thinkphp / queue.c
Created December 11, 2019 19:32
Queue Data Structure
/**
* Queue Data Structure implemented as Array
*/
#include <stdio.h>
#define QUEUE_MAX 5
//declare my queue and two pointers to this data structure
int queue[ QUEUE_MAX ],
front = -1,
rear = -1;