Skip to content

Instantly share code, notes, and snippets.

View crimx's full-sized avatar

CRIMX crimx

View GitHub Profile
@crimx
crimx / Singleton pattern.java
Created April 14, 2014 15:13
Singleton pattern
public class Singleton {
private static Singleton instance = null;
private Singleton() {
//dosomething
}
public static synchronized Singleton getInstance() {
if(instance == null) {
instance = new Singleton();
}
return instance;
@crimx
crimx / insertion_sort.c
Created April 12, 2014 04:52
Insertion sort template
int Isort(int a[], int s, int e) {
int i, j, t;
for(i=s+1; i <= e; i++) {
t = a[i];
for(j = i-1; j>=s && a[j]>t; j--)
a[j+1] = a[j];
a[j+1] = t;
}
}
@crimx
crimx / qsort.c
Last active August 29, 2015 13:59
Quick Sort Template
void Qsort(int a[], int s, int e) {
if(s>=e) return;
int p=s, q=e, t;
int k = getPivot(a,s,e);
t = a[k];
a[k] = a[s];
while(p<q) {
while(p<q&&a[q]>=t) q--;
a[p] = a[q];
while(p<q&&a[p]<=t) p++;
M[16],X=16,W,k;
main() {
T(system("stty cbreak"));
puts(W&1 ? "WIN":"LOSE");
}
K[]={2,3,1};
s(f,d,i,j,l,P) {
for(i=4; i--; )
for(j=k=l=0; k<4; )