This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define stringize(s) #s | |
enum subjects { | |
maths, | |
history, | |
programming, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int CalculateFullTriplets(int s) | |
{ | |
int t = 0; | |
while (s - 3 > 0) | |
{ | |
s -= 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
struct node { | |
int data; | |
struct node *next; | |
}; | |
struct stack { | |
struct node *head; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Static stack implementation | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#define STACK_SIZE 10 | |
void show_stack(int *s, int stack_top) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
struct queue_node | |
{ | |
char x; | |
struct queue_node *next; | |
}; | |
struct queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
size_t _strlen(const char *s) | |
{ | |
size_t size = 0; | |
while (*s++) | |
++size; | |
return size; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
OlderNewer