2011年9月13日 星期二

Linux-tar

tar是Linux上用來封裝(打包)檔案用的

tar [-j|-z] [-cv] -f tar_name target
打包target

tar [-j|-z] [-tv] -f tar_name
察看tar之檔

tar [-j|-z] [-xv] -f tar_name [-C director]
解開tar
-C可指定愈放置檔案之目錄
預設是在當前目錄

-j -z 不要亂加
-j為支援bzip2,tarname要是*.tar.bz2
-z為支援gzip,tarname要是*.tar.gz

-c 打包
-t 察看
-x 解開
-v 顯示詳細內容
-f 檔案
一般用此即可
tar -cvf xxx.tar file
tar -xvf xxx.tar [-C director]

2011年9月1日 星期四

Algorithms-simple binary search

first,you need sort

then you could search the 'numeber'

variable t show the recursive times

code:

2011年8月23日 星期二

C-集合

列出{1,2,....,n}之所有子集,包括空集合ϕ

code:(參考名題百則)


notion:
產生布林表
利用i,j找出對應值
0000 --> {}
1000 --> {1}
0100 --> {2}
1100 --> {1,2}
0010 --> {3}
1010 --> {1,3}
0110 --> {2,3}
依此類推

2011年8月15日 星期一

Linux vim copy and paste

if copy and paste can't work

in vim

:h gui-clipboard

add this line in _vimrc
source $VIMRUNTIME/mswin.vim

2011年7月1日 星期五

C/C++ - rand()

#include<stdlib.h>

if you need a random number between a(min) and b(max) ,
use:

int x = (rand()%(max-min+1))+min

usually use srand() to build random base

ex:
1 int randnum(int min,int max)
2 {
3         int a;
4         srand(time(NULL));
5         a =(rand()%(max-min+1))+min;
6         return a;
7 }

time() include time.h
rand() and srand() include stdlib.h