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
| 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; ) |
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
| 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++; |
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
| 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; | |
| } | |
| } |
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
| public class Singleton { | |
| private static Singleton instance = null; | |
| private Singleton() { | |
| //dosomething | |
| } | |
| public static synchronized Singleton getInstance() { | |
| if(instance == null) { | |
| instance = new Singleton(); | |
| } | |
| return instance; |
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
| package com.crimx.adapter; | |
| public class Adapter implements Plug2{ | |
| private Plug1 plug1; | |
| public Adapter(Plug1 p1) { | |
| Plug1 = p1; | |
| } | |
| public void slot1() { |
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
| void swap(char *a, char *b) { | |
| *a = *a^*b; | |
| *b = *a^*b; | |
| *a = *a^*b; | |
| } | |
| void reverse(char *a) { | |
| if(!a) return; | |
| int i, n = -1; | |
| while(a[++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
| String.prototype.slice(start[,end]); If a negative number is given, it is treated as strLength + start/end. | |
| String.prototype.substr(start[,length]); If a negative number is given to start, it is treated as strLength + start. | |
| String.prototype.substring(indexA[,indexB]); If either argument is less than 0 or is NaN, it is treated as if it were 0. | |
| If either argument is greater than stringName.length, it is treated as if it were stringName.length. | |
| var s1 = "0123456789" | |
| console.log(s1.slice(3, 7)); //"3456" |
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
| window.myApp = (function (myApp) { | |
| /* | |
| * 123456 --leftShift+2--> 345612 | |
| * 1. 12 | 3456 | |
| * 2. 21 | 3456 | |
| * 3. 21 | 6543 | |
| * 4. 216543 | |
| * 5. 345621 | |
| */ | |
| myApp.leftShift = function (arr, offset) { |
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
| window.myApp = (function (myApp) { | |
| // O(m+n) | |
| myApp.containChar = function (Str1, Str2) { | |
| if (typeof Str1 !== "string" || typeof Str2 !== "string") { | |
| return; | |
| } | |
| var longStr, |
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
| var arr = []; | |
| for (var i=0; i< 10000; i++) { | |
| arr[i] = Math.floor(Math.random()*9997+1); //1~9998 | |
| } | |
| // console.log(a); | |
| function sort(arr) { | |
OlderNewer