Skip to content

Instantly share code, notes, and snippets.

View boki1's full-sized avatar
🧐

Kristiyan Stoimenov boki1

🧐
View GitHub Profile
@boki1
boki1 / students_sort.c
Last active April 29, 2019 20:53
Student Sorting - School HW - 24/04/2019
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define stringize(s) #s
enum subjects {
maths,
history,
programming,
@boki1
boki1 / totext.c
Created April 27, 2019 22:02
From digits to text - School First HW
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int CalculateFullTriplets(int s)
{
int t = 0;
while (s - 3 > 0)
{
s -= 3;
@boki1
boki1 / quicksort.c
Created April 27, 2019 22:03
Quicksort implementation - School HW - 21/04/2019
#include <stdio.h>
#include <stdlib.h>
#define swap(x, y) ((&(x) == &(y)) ? (x) : ((x)^=(y), (y)^=(x), (x)^=(y)))
#define dim(arr) (sizeof(arr) / sizeof(*arr))
int make_partition(int arr[], int beg, int end)
{
int pivot = arr[end], i = beg - 1;
for (int j = beg; j < end; ++j)
@boki1
boki1 / convert.c
Created April 27, 2019 22:07
Convertion between different numerical systems - School HW
#include <stdio.h>
#include <stdlib.h>
#define DECODE_STR "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
#define DECODE_STR_LENGTH 62
int d2v(char c) {
int idx = 0;
while (DECODE_STR[idx] != c && idx < DECODE_STR_LENGTH) ++idx;
return idx;
@boki1
boki1 / bitmap.c
Last active March 17, 2021 19:58
Bitmap - School HW
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define BITS_IN_INT sizeof(int) * CHAR_BIT
#define BITMAP_SIZE (UCHAR_MAX + 1) / BITS_IN_INT
void set(int bitmap[], int bit, int val)
{
int mask = 1 << bit % BITS_IN_INT;
@boki1
boki1 / dynamic_stack.c
Created April 27, 2019 22:16
Dynamic stack implementation - School HW
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
struct stack {
struct node *head;
@boki1
boki1 / static_stack.c
Created April 27, 2019 22:17
Static stack implementation - School HW
// Static stack implementation
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define STACK_SIZE 10
void show_stack(int *s, int stack_top)
{
@boki1
boki1 / dynamic_queue.c
Last active April 25, 2022 18:47
Dynamic queue implementation - School HW
#include <stdio.h>
#include <stdlib.h>
struct queue_node
{
char x;
struct queue_node *next;
};
struct queue
@boki1
boki1 / str.c
Created May 6, 2019 20:44
Implementation of c stdlib functions strlen, strcpy & strcpy
#include <stdio.h>
#include <stdlib.h>
size_t _strlen(const char *s)
{
size_t size = 0;
while (*s++)
++size;
return size;
}
@boki1
boki1 / r_sort.c
Last active May 17, 2019 19:07
Radix sort -> sort by bit mask
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#define mask_default 1 << 3
#define len(arr) sizeof(arr) / sizeof(*arr)
void r_sort(unsigned *start, unsigned *end, unsigned mask) {
if (start == end || !mask)
return;