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
/** | |
* 给一个数组和一个值,从数组中删除这个指定的值的所有出现,并且返回新的数组的长度。 | |
* size_t remove_elem(T* array, size_t len, T elem) {}。 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char* argv[]){ |
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 KMP1 { | |
public static int kmp1(String pattern, String src){ | |
int srcLength = src.length() ; | |
int patternLength = pattern.length() ; | |
int index = -1 ; | |
int count = 0 ; | |
for(int i = 0 ; i < srcLength - 1 ;){ | |
count = 0 ; | |
for(int j = 0 ; (j < patternLength ) && (i < srcLength) ; j++){ | |
if(src.charAt(i) == pattern.charAt(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
Original String: | |
I couldn't believe that I could actually understand what I was reading: | |
the phenomenal power of the human mind. According to a research team at Cambridge University, | |
it doesn't matter in what order the letters in a word are, the only important thing is that the | |
first and last letter be in the right place. The rest can be a total mess and you can still read | |
it without a problem. This is because the human mind does not read every letter by itself, but the | |
word as a whole. Such a condition is appropriately called Typoglycemia. Amazing, huh? Yeah and you | |
always thought spelling was important. | |
Converted String: |
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
#!/usr/bin/env python | |
''' | |
This script is used to test sid stats in player p2p stats. | |
Created on 2012-11-14 | |
@author: caoxudong | |
''' |
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 test.java.lang.string; | |
import java.util.regex.Pattern; | |
public class TestString { | |
public static void main(String[] args) { | |
String a = null; | |
a += "a"; |
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
n = 1000 | |
a = 1 | |
b = 1 | |
c = 1 | |
result = 0 | |
while a < n: | |
b = a + 1 | |
while b < n: | |
c = b + 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
/** | |
* 将16进制字符串转换为对应的字节数组。 | |
* 其中,字符串中每两个字节作为结果数组中的一个字节的内容的16进制表示 | |
* / | |
char peerId[] = {"0fd5081f306494b7b290c2ef9594c56613212b4945d8ece8fcb832ad1d33a169"}; | |
std::string realPeerId; | |
char tempCh = 0; | |
for (char* ch = peerId; *ch != 0; ch += 2) { |
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
//用于将cstring转为char* | |
CString peerIdCString = _T("e0f4111df2a7d6bf591619884e353452bccb26c5a8ffa18079061d16f533fe1e"); | |
USES_CONVERSION; | |
char* buffer = T2A(peerIdCString); |
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
#!/usr/bin/env python | |
class Node: | |
data = None | |
next = None | |
def __init__(self,lndata): | |
self.data=lndata | |
class List: | |
size = 0 |
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
#!/usr/bin/env python | |
import os | |
def hanoiRecursively(fromBar, intermediateBar, toBar, number): | |
if number == 1: | |
print 'move 1 from ' + fromBar + ' to ' + toBar | |
else: | |
hanoiRecursively(fromBar, toBar, intermediateBar, number - 1) | |
print 'move ' + str(number) + ' from ' + fromBar + ' to ' + toBar |
OlderNewer