Skip to content

Instantly share code, notes, and snippets.

View shonenada's full-sized avatar
🤷‍♂️
Focusing

Yaoda Liu shonenada

🤷‍♂️
Focusing
View GitHub Profile
@shonenada
shonenada / kmp.java
Created December 12, 2012 10:50
kmp in java
package Notepad;
public class KMP {
static int[] getNext(String p){
int i=1,j=0;
int[] next = new int[p.length()+2];
char[] pattern = p.toCharArray();
next[0] = -1;
@shonenada
shonenada / DFrame.java
Created December 12, 2012 10:54
my notepad in java
package Notepad;
import java.awt.*;
import javax.swing.*;
import java.awt.Toolkit;
public abstract class DFrame extends JFrame{
/**
@shonenada
shonenada / binarysearch.cpp
Created December 12, 2012 11:14
Binary Search in c++
#include<iostream>
using namespace std;
int BS(int* arr, int n, int key){
int low, high, mid;
low = 0;
high = n-1;
while(low<=high){
mid = (low+high) >> 1;
@shonenada
shonenada / RecuirsiveBinSearch.cpp
Created December 12, 2012 11:25
Binary Search Recursive
#include<iostream>
using namespace std;
int bs(int* a, int key, int low, int high){
int mid;
mid = (low+high) / 2 ;
if(low>high){
return -1;
}
@shonenada
shonenada / BinSortTree.cpp
Created December 12, 2012 11:32
Binary Sort Tree
struct BinNode {
int data;
BinNode *lChild, *rChild;
};
class BinSortTree{
public:
BinSortTree();
~BinSortTree();
void SearchBST(int);
void CreateBST(int *, int);
@shonenada
shonenada / compare two files.py
Created March 12, 2013 08:55
Compare two files, show which line is not equal..
file1 = open("file1", "r")
file2 = open("file2", "r")
line1 = file1.readlines()
line2 = file2.readlines()
for i in range(0, len(line1)):
if(line1[i] != line2[i]):
print i+1
@shonenada
shonenada / BmpIO.cpp
Created March 12, 2013 09:09
BMP 图像处理,包括去色,反色,左右翻转,上下翻转。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;
typedef struct
{
char type1;
char type2;
}BmpFileHead;
#include<iostream>
using namespace std;
int i=0;
bool chk();
bool c();
void main(){
chk();
}
bool chk(){
i >=1000 || i++,cout << i << " ";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;
typedef struct
{
char type1;
char type2;
}BmpFileHead;
@shonenada
shonenada / Gauss.py
Last active December 15, 2015 21:28
高斯列主元消去法
#-*-coding: utf-8 -*-
EPS = 1.0e-4
def guass(A, b):
""" 高斯消元法
输入要求:
A = [[x11, x12, x13], [x21, x22, x23], [x31, x32, x33]]