Skip to content

Instantly share code, notes, and snippets.

View cristiancrazy's full-sized avatar
Studying C... again😩

Cristian cristiancrazy

Studying C... again😩
View GitHub Profile
/*
Recursive function to:
- Search elements on arrays
- Count elements on arrays
*/
// Find the needle on the a;
// n = the last element index on array
// equals to arraysize-1
int getElement(int a[], int needle, int n){
@cristiancrazy
cristiancrazy / SimplePlugs.c
Last active December 6, 2023 09:58
C - Basic Plug Vector's utilities
/* ================================== *
* Author: CristianCrazyIT
* Date: 6-12-2023 (dmy)
* Desc: Vector Plug Utilities
* ================================== */
#include <stdio.h>
#include <stdlib.h>
/**
@cristiancrazy
cristiancrazy / search.c
Last active November 8, 2023 10:02
C - Binary and Sequential search
/* ================================== *
* Author: CristianCrazyIT
* Date: 02-11-2023 (dmy)
* Desc: Simple Searching Functions
* ================================== */
// Binary Search
int search(int* v, int n, int needle){
int i = 0, j = n-1, m;
while(j >= i){
@cristiancrazy
cristiancrazy / SimpleSorting.c
Created November 2, 2023 14:00
Basic array sorting functions, including Selection Sort and Bubble Sort
/* ================================== *
* Author: CristianCrazyIT
* Date: 02-11-2023 (dmy)
* Desc: Simple Sorting Functions
* ================================== */
/* Selection Sort on int array[N-Dimension] */
void selectionSort(int array_in[], int N){
int min, tmp;
for(int i = 0; i < N; i++){
@cristiancrazy
cristiancrazy / WorkingCMS.java
Last active December 6, 2023 09:37
BouncyCastle: get instance of EC private key / CMS from a string, and decrypt CMS (PEM) files.
/* ==========================================
* Author: Cristian Capraro
* Date: 03-09-2023
* Working with: BouncyCastle & Java Security
* :: Cryptographic Message Syntax
* ========================================== */
package cmsoperations;
import java.security.KeyFactory;