This file contains hidden or 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
| char is_prime(long n) { long i=1; while (n > 1 && n % ++i); return i >= n; } |
This file contains hidden or 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> | |
| unsigned bintoint(char s[]) { | |
| int i, l; | |
| unsigned v = 0; | |
| for (l=-1; s[l+1] != '\0'; ++l); | |
| for (i=l; i>=0; --i) | |
| v += (s[i]-'0')<<(l-i); | |
| return v; | |
| } |
This file contains hidden or 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
| #!/bin/sh | |
| # gendata.sh | |
| function print_ij() { | |
| # print j'th field (column) of the i'th line | |
| awk -v i=$1 -v j=$2 'FNR == i {print $j}' $3 | |
| } | |
| function gendata() { | |
| n=$(($1 - 1)) |
This file contains hidden or 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 "genlist.h" | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| void init_list(struct list **p, unsigned tail, unsigned loop) { | |
| if (*p != NULL) { | |
| fprintf(stderr, "init_list: base pointer not NULL\n"); | |
| return; | |
| } | |
This file contains hidden or 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
| #ifndef _PROB_BENCHMARK_H_ | |
| #define _PROB_BENCHMARK_H_ | |
| #define _GNU_SOURCE | |
| #include <stdio.h> | |
| #include <time.h> | |
| #define KNRM "\x1B[0m" // normal console color | |
| #define KRED "\x1B[31m" |
This file contains hidden or 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> | |
| typedef struct mat { | |
| int rows; | |
| int cols; | |
| int **e; | |
| } mat; | |
| mat *create_matrix(int i, int j); |
This file contains hidden or 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> | |
| void heapify(int *a, int len); | |
| void heapsort(int *a, int len); | |
| void siftdown(int *a, int p, int len); | |
| void printa(int *a, int len); | |
| int main(int argc, char *argv[]) | |
| { | |
| int arr[10] = {1,2,4,-41,4,13,3,2,40,-4}; |
This file contains hidden or 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
| #!/bin/sh | |
| # put this in .bashrc or /etc/bashrc | |
| function fsize() { | |
| kB=1000 | |
| val=$(stat --printf="%s" $1) | |
| if [ $val -lt $kB ]; then | |
| printf "$val B\n" | |
| elif [ $val -lt $(($kB*$kB)) ]; then | |
| printf "%0.2lf KB\n" $(bc -l <<< "$val/$kB") |
This file contains hidden or 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
| # makefile for glfw | |
| CFLAGS=$(shell pkg-config --cflags glfw3) | |
| LDFLAGS=$(shell pkg-config --libs glfw3) -lGL -lm | |
| all: | |
| $(CC) $(CFLAGS) glfwtest.c -o glfw_test $(LDFLAGS) | |
| clean: | |
| $(RM) glfw_test |
This file contains hidden or 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 <pthread.h> | |
| #include <sys/sysinfo.h> | |
| #define UBOUND 1000000000 | |
| void *tfunc(void *arg); | |
| int main(int argc, char *argv[]) |