2009年10月22日 星期四

Longest Common Subsequence (LCS)

Longest Common Subsequence,中文可以稱做最長子序列,這個問題的定義如下:

給定兩個序列,求其最長相同的子序列。此問題和Longest Common Substring不同,Substring中間不可以有斷點,但是subsequence可以。

問題分析:

 

  1. 令序列1為S1,序列2為S2
  2. 令S1 = Sub1 + elm1, S2 = Sub2 + elm2
  3. 其中elmi就是我們要求的LCS,因此有四個可能
    1. elm1是LCS的一部分而elm2不是
    2. elm2是LCS的一部分而elm1不是
    3. elm1, elm2都是LCS
    4. elm1, elm2都不是LCS

寫程式的話,就依照Dynamic programming的方式,依次的填入表格就可以,但是如何找出我們要的LCS呢?這須要back tracing才有辦法。留著下回分解吧(如果我有空的話..>"<)。

程式碼如下:

#include <iostream>
#include <iostream>
#include <iostream>
#include <iostream>
using namespace std;
void lcs(string& s, string& t);
void lcs(string& s, string& t) {
    unsigned int** c = new unsigned int*[s.length()];
    for(unsigned int i = 0; i < s.length(); ++i) {
        c[i] = new unsigned int[t.length()];
    }
    for(unsigned int i = 0; i < s.length(); ++i) {
        for(unsigned int j = 0; j < t.length(); ++j) {
            c[i][j] = 0;
        }
    }
    for(unsigned int i = 1; i < s.length(); ++i) {
        for(unsigned int j = 1; j < t.length(); ++j) {
            if(s[i] == t[j]) {
                c[i][j] = c[i-1][j-1] + 1;
            } else {
                c[i][j] = max(c[i][j-1], c[i-1][j]) ;
            }
        }
    }
    for(unsigned int i = 0; i < s.length(); ++i) {
        for(unsigned int j = 0; j < t.length(); ++j) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}

int main(int argc, char* argv[])
{
    
    char szs[1024] = {0}, szt[1024] = {0};
    string s, t;
    cout << "please a string without white space.." << endl;
    cin.getline(szs, 1024);
    s = szs;
    s.insert(s.begin(), '0');
    cin.getline(szt, 1024);
    t = szt;
    cout << "please a string without white space.." << endl;
    t.insert(t.begin(), '0');
    cout << "counting..." << endl;
    lcs(s, t);
	return 0;
}

2009年10月20日 星期二

PS Tray Factory



好用的PS Tray Factory,可以把一堆在系統圖示上的icon全都收在一起,這樣看起來System Tray就乾淨多了不是嗎?其實把tray icon收起來的功能在Windows 7上面也有喔,但PS Tray Factory的功能比較多,而且可以把最小化後的application也收進去,但是不太穩定,在還沒有換Win7之前,就先用這個吧...

PS: 這套軟體是要付錢的...

2009年10月19日 星期一

#P-Complete

A problem is #P-complete if and only if it is in #P, and every problem in #P can be reduced to it by a polynomial-time counting reduction.

難嗎,其實還好,定義看上去很簡單,只是要找到問題有點難。#P-Complete的難度比起NP-Complete的難度,是在之上,或是和此問題的一樣難。

證明的流程如下:

找一個polynomial-time的function使得這個問題的(每一個)解,可以使用這個function對應到另一個己被證實的#P-complete上面。

看起來和NP-Complete很像對吧。難度在於"每一個"解。也就是說#P的意思在於counting all solutions.

# = number就對啦...

目前已被證實為#P-Complete的問題並不多,因為要找到一個NP-Complete的解就不簡單了,更何況是算出有多少解。 

這裡有一個迷思就是,我可以不用知道所有的解,而算出解的個數嗎!?

也許這是另一種解#P-Complete的方法,但是.還是沒有人提出這樣的證明,因為#P-Complete的難度,至少有NP-Complete這麼難...

研究所二年級時,每天都在看這問題..看過的有..

Counting LCS is #P-complete. Counting random walk solutions is #P-Complete. Counting SAT solutions is #P-Complete.

所以我們幾乎可以說,只要一個問題是NP-Complete,那麼記算他所有的解"應該"就是#P-Complete。至於為什麼用應該呢?因為上面有說過了,說不定有公式求個數解..

於是,只要找到一個plynomial time的解法解出#P-Complete,那麼NP=P, P=PH..

哪有可能找到..2SAT不落於NP-Complete但Counting 2SAT都是#P-Complete了..所以難度的成長快很多..還是等哪位天才快來證明NP!=P吧..

 

2009年9月29日 星期二

百恋歌

これが恋だと知りました 川を流れる花でした

終於知道這就是戀愛 如同在河川中被流走的花

追いかけても手が届かない 薄紅の花でした

即使不斷追尋也碰觸不到 淡紅色的花

 

彩なす空 走る夕立ち 遠ざかる蝉時雨

絢麗的天空 流逝的夕陽 遠去的雷陣雨

人は誰も振り返るまで 時の流れに気づかない

誰都是在驀然回首時 才會察覺時間的流逝

 

泣いて泣いて 泣くだけ泣いて

哭泣 哭泣 就這樣的哭著

見上げる星空は万華鏡

抬頭仰望的星空卻變成了萬花筒

いつかあなたに届くように

何時才能夠傳達給你

歌う 百恋歌

我唱的 百戀歌

 

それが愛だと知りました 夜空に浮かぶ月でした

終於明白那就是戀愛 如同夜空中浮升的月亮

背伸びしても手を伸ばしても 届かない月でした

就算是掂起腳尖伸長手臂 都碰不著的月光

 

迷い桜 はぐれた燕 追いかける影法師

亂舞的櫻花 逸去的燕子 逼近的陰影

人は誰も目を覚めすまで それが夢だと気づかない

誰都是在睜開雙眼時 才會發現只是一場夢

 

春は野を駆ける風になり

春天時化為荒野中奔馳的風

夏は蒼く萌える海になり

夏天時化作孕育蒼藍的海洋

いつかあなたの腕の中で

何時能夠在你的臂彎裡

歌う 百恋歌

唱著 百戀歌

 

秋は七色に身を染めて

秋天時將七色點綴在身上

冬は春を探す鳥になり

冬天時就化為探尋春天的小鳥

いつかあなたの腕の中で

何時能夠在你的臂彎裡

歌う 百恋歌

唱著 百戀歌

 

2009年9月23日 星期三

八皇后問題(8クイーンの問題)

Wiki對八皇后問題的定義如下:
八皇后問題是一個以西洋棋為背景的問題:如何能夠在 8×8 的西洋棋棋盤上放置八個皇后,使得任何一個皇后都無法直接吃掉其他的皇后?為了達到此目的,任兩個皇后都不能處於同一條橫行、縱行或斜線上。八皇后問題可以推廣為更一般的n皇后擺放問題:這時棋盤的大小變為n×n,而皇后個數也變成n若且唯若 n = 1 或 n ≥ 4 時問題有解。

寫程式求解,最方便的方法便是窮舉法,也因為這個問題是算是所有的解的個數,所以是一個counting problem,如果以上下限來探究這個問題,這個問題比EXP成長的還要快。所以目前為止沒有很有效率的解法,有的只是少算一半或是少算1/4或1/8,但大家都知道,這對算法本身是一樣的時間的order。

最主要的步驟在於如何檢驗棋盤中的[i, j]是不是能放一個queen,一般檢察都是以"米"字方法檢驗,但是因為我們是由上而下擺放,故下方所有的檢驗可以不做,又因為位於任一row上面的第i個column上若有一個皇后,也等同於在第n-i column上的解(鏡射方法),所以我們只要對第一個row求出n/2個column的解就完成了(total的解的個數當然要*2)。如果是奇數也不用擔心先把前面n/2求A個解再求一個n/2+1有B個解,total解法就是2A+B。

在我的電腦裡算出的時間如下 (P4 D 3.4G CPU):

n = 1 ~ 11, 0秒
n = 12, 1秒 (14200解)
n = 13, 3秒 (73712解)
n = 14, 18秒 (365596解)
n = 15, 134秒 (2279184解)
n = 16, 909秒 (14772512解)
n = 17, 7312秒 (95815104解) <=快破億了

有沒有辦法再加快呢?答案是有的,程式部分我並沒有做最佳化,而且compiler也沒打開最佳化,另外所有的variables都改為global也會變快,減少for的週算次數也很重要,也可以再調整一下檢驗的順序。經過實驗,這個解比起Wiki提供的還要快,因為少算了一半吧。

程式如下:

// NQueen.cpp : Defines the entry point for the console application.
//

#include "NQueen.h"
#include <iostream>
#include <time.h>
using namespace std;

int *boardMap;
int queenCount = 0;
int totalSolution = 0;
int main(int argc, char* argv[], char* envp[])
{
    if(argc != 2) {
        cout << "Please input a number..." << endl;
        return 0;
    }
    makeMap((queenCount = atoi(argv[1])));
    time_t start,end;
    double dif;
    time (&start);
    specialCount();
    time (&end);
    dif = difftime(end,start);
    printf("It takes %.2f seconds to count %ld queens' solutions...\n", dif, queenCount);
    cout << "Total solution: " << totalSolution << endl;
    return 0;
}

void makeMap(int n) {
    boardMap = new int[n];
    for(int i = 0; i < n; ++i) {
        boardMap[i] = -1;
    }
}
void deleteMap() {
    delete [] boardMap;
}

void count2(int row, int i) {
    for(register int j = 0; j < queenCount; ++j) {
        if(check8Directions2(row, j)) {
            boardMap[row] = j;
            if(row != queenCount-1) {
                count2(row+1, 0);
            } else {
                totalSolution ++;
            }
        }
        boardMap[row] = -1;
    }
}

void specialCount() {
    if(queenCount == 1) {
        totalSolution = 1;
        return;
    }
    for(int i = 0; i < queenCount / 2; ++i) {
        boardMap[0] = i;
        count2(1, 0);
    }
    int currentTotalCount = totalSolution;
    totalSolution = 0;
    if(queenCount % 2 == 1) {
        boardMap[0] = queenCount / 2;
        count2(1, 0);
    }
    totalSolution = totalSolution + currentTotalCount * 2;
}

bool check8Directions2(int row, int j) {
    register int i = 0;
    for(i = 0; i <= row; ++i) {
        if((boardMap[i] == j))
            return false;
    }
    for(i = 1; i <= row; ++i) {
        if((boardMap[row-i] == j-i) || (boardMap[row-i] == j+i))
            return false;
    }
    return true;
}

2009年9月21日 星期一

c#聊天室(チャットルーム)

C#聊天室(Chatroom)

編譯環境:Visual Studio 2008 C#
程式碼(ソースコード):在這裡(here)
說明:

使用TcpClient實作的chatroom,目前已完成多人連線版本,只要再做修改,就可以實際使用於很多場合。我相信這是很多人的作業,所以就放上原始碼讓大家參考了,如果有任何問題也觀迎在我的blog上留言。

2009年9月13日 星期日

Jubeat Score Editor (Jubeat譜面編輯器)

System Requirment:
Windows XP sp2 or sp3, .Net framework 3.5 or later. Windows Vista, Windows 7.

Release Note:
[2009.09.14]1.0版完成。發佈..
[2009.10.01]1.1版完成,更新按鈕圖示、新增刪除譜面功能及一些bugs...發佈..

已經完成了,操作如下:

1.0 Download
1.1 Download

  1. 打開程式
    畫面如下
  2. 按下左上方的小圖示

    按下後畫面會多出現一個譜面編輯
  3. 在16格上面按下任何一個,就會出現編輯畫面,完成後記得按下Enter


  4. 按下存檔就可以存成像這下這樣的格式


  5. 開檔就選擇存好,或是手動編好的檔案就可以了。
  6. 程式如果還有任何問題,請和我說,我會再修改。

PS: 下一版發行可以存成譜面表示機可以讀取的檔案。

 

2009年8月31日 星期一

C# Bezier Curve


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CSharpBezierCurve
{
    public partial class Form1 : Form
    {
        private Point[] controlPoint = new Point[4];
        private int controlPointCount = 0;
        public Form1()
        {
            InitializeComponent();
        }


        private void drawControlLine(Graphics g) {
            Pen p = new Pen(Color.Green);
            if (!controlPoint[0].IsEmpty && !controlPoint[1].IsEmpty)
                g.DrawLine(p, controlPoint[0], controlPoint[1]);
            if (!controlPoint[1].IsEmpty && !controlPoint[2].IsEmpty)
                g.DrawLine(p, controlPoint[1], controlPoint[2]);
            if (!controlPoint[2].IsEmpty && !controlPoint[3].IsEmpty)
                g.DrawLine(p, controlPoint[2], controlPoint[3]);
        }

        private void drawBezierCurve(Graphics g) {
            Pen p = new Pen(Color.Aqua);
            g.DrawBezier(p, controlPoint[0], controlPoint[1], controlPoint[2], controlPoint[3]);
        }

        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (controlPointCount == 4) return;
            controlPoint[controlPointCount++] = new Point(e.X, e.Y);
            Pen p = new Pen(Color.Red);
            Panel panel = (Panel)sender;
            Graphics g = panel.CreateGraphics();
            g.DrawRectangle(p, e.X, e.Y, 2, 2);
            drawControlLine(g);
            if (controlPointCount == 4) drawBezierCurve(g);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            controlPoint = null;
            controlPoint = new Point[4];
            controlPointCount = 0;
            panel1.Invalidate();

        }

    }
}

Java Queue Implement

雖然原本的Java就有這個東西了,但是還是實作一下。

class JElemrnt {
  public JElemrnt prev;
  public T value;
  public JElemrnt next;
    
  public JElemrnt(T t) {
    prev = null;
    next = null;
    value = t;
  }
}

public class JQueue {
  
  JElemrnt head;
  JElemrnt tail;

  int queueSize;
  public JQueue() {
    queueSize = 0;
    head = null;
    tail = null;
  }
  public void enqueue(T t) {
    JElemrnt tmp = new JElemrnt(t);
    if(queueSize == 0) {
      head = tmp;
      tail = tmp;
    } else {
      tmp.prev = tail;
      tail.next = tmp;
      tail = tmp;
    }
    ++queueSize;
    System.out.println("Enqueue Element: " + t.toString());
    System.out.println("Now queue size is: " + queueSize);
  }
  public T dequeue() {
    if(head == null || tail == null) {
      return null;
    }
    T retVal = tail.value;
    tail = tail.prev;
    //tail.next = null;
    --queueSize;
    System.out.println("Dequeue Element: " + retVal.toString());
    System.out.println("Now queue size is: " + queueSize);
    if(queueSize == 0) {
      head = null;
      tail = null;
    }
    return retVal;
  }
  public T query(int n) {
    if(n > queueSize) return null;
    return null;
  }
  public static void main(String[] argv) {
    System.out.println("Starting queue demo...");
    JQueue q = new JQueue();
    Integer i1 = new Integer(1);
    Integer i2 = new Integer(2);
    Integer i3 = new Integer(3);
    q.enqueue(i1);
    q.enqueue(i2);
    Integer de = q.dequeue();
    q.enqueue(i3);
    de = q.dequeue();
    de = q.dequeue();
    System.out.println("Ending queue demo...");
  }
}

How to Build Android USB Driver

 

  1. Please install Git
  2. Get the code from http://android.git.kernel.org/
  3. The site should be git://android.git.kernel.org/platform/development.git
  4. On your disk, you will find a folder named "\host\windows\usb\legacy\driver". This is the Android USB Driver.
  5. Please install WDK 6000, I have test to build the driver with WDK 7000, but there are some issues when building.
  6. Open the WDK build enviroment and Change the location into the folder, just press "build" will be ok!!

This is the picture after building.


If you try to build the driver with WDK 7000, You will find the error!! "link : error LNK1117: syntax error in option 'MAPINFO:LINES'"

I am sick of M$ to provide so suck WDK pack, so please build it with WDK 6000.



Windows 可執行程式

CMD部分

 

accwiz.exe      ------         輔助工具嚮導 

acsetups.exe    ------         acs setup dcom server executable 

actmovie.exe    ------         直接顯示安裝工具 

append.exe      ------         允許程式打開制定目錄中的資料 

arp.exe         ------         顯示和更改電腦的ip與硬體物理位址的對應列表 

asadmin.exe     ------         start the remote access admin service 啟動遠端存取服務 

at.exe          ------         計畫運行任務 

atmadm.exe      ------         調用管理器統計 

attrib.exe      ------         顯示和更改檔和檔夾屬性 

autochk.exe     ------         檢測修復檔系統 

autoconv.exe    ------         在啟動過程中自動轉化系統 

autofmt.exe     ------         在啟動過程中格式化進程 

autolfn.exe     ------         使用長檔案名格式 

bootok.exe      -----          boot acceptance application for registry 

bootvrfy.exe    ------         通報啟動成功 

cacls.exe       ------         顯示和編輯acl 

calc.exe        ------         計算器 

cdplayer.exe    ------         cd播放器 

change.exe      ------         與終端伺服器相關的查詢 

charmap.exe     ------         字元對應表 

chglogon.exe    ------         啟動或停用會話記錄 

chgport.exe     ------         改變埠(終端服務) 

chgusr.exe      ------         改變用戶(終端服務) 

chkdsk.exe      ------         磁片檢測程式 

chkntfs.exe     ------         磁片檢測程式 

cidaemon.exe    ------         組成ci文檔服務 

cipher.exe      ------         在ntfs上顯示或改變加密的檔或目錄 

cisvc.exe       ------         索引內容 

ckcnv.exe       ------         變換cookie 

cleanmgr.exe    ------         磁片清理 

cliconfg.exe    ------         sql客戶網路工具 

clipbrd.exe     ------         剪貼簿查看器 

clipsrv.exe     ------         運行clipboard服務 

clspack.exe     ------         建立系統檔列表清單 

cluster.exe     ------         顯示域的集群 

cmd             ------         顯示版本

cmdl32.exe      ------         自動下載連接管理 

cmmgr32.exe     ------         連接管理器 

cmmon32.exe     ------         連接管理器監視 

cmstp.exe       ------         連接管理器配置檔安裝程式 

comclust.exe    ------         集群 

comp.exe        ------         比較兩個檔和檔集的內容* 

compact.exe     ------         顯示或改變ntfs分區上檔的壓縮狀態 

conime.exe      ------         ime控制臺 

control.exe     ------         控制面板 

convert.exe     ------         轉換檔系統到ntfs 

convlog.exe     ------         轉換iis日誌檔格式到ncsa格式 

cprofile.exe    ------         轉換顯示模式 

cscript.exe     ------         較本宿主版本 

csrss.exe       ------         客戶伺服器runtime進程 

csvde.exe       ------         日至格式轉換程式 

dbgtrace.exe    ------         和terminal server相關 

dcomcnfg.exe    ------         dcom配置屬性 

dcphelp.exe     ------         

dcpromo.exe     ------         ad安裝嚮導 

ddeshare.exe    ------         dde共用 

ddmprxy.exe     ------         

debug.exe       ------         就是debug啦! 

dfrgfat.exe     ------         fat分區磁片碎片整理程式 

dfrgntfs.exe    ------         ntfs分區磁片碎片整理程式 

dfs_cmd_.exe    ------         配置一個dfs樹 

dfsinit.exe     ------         分散式檔系統初始化 

dfssvc.exe      ------         分散式檔系統伺服器 

diantz.exe      ------         製作cab文件 

diskperf.exe    ------         磁片性能計數器 

dllhost.exe     ------         所有com+應用軟體的主進程 

dllhst3g.exe    ------         

dmadmin.exe     ------         磁片管理服務 

dmremote.exe    ------         磁片管理服務的一部分 

dns.exe         ------         dns applications dns 

doskey.exe      ------         命令行創建宏 

dosx.exe        ------         dos擴展 

dplaysvr.exe    ------         直接運行幫助 

drwatson.exe    ------         華生醫生錯誤檢測 

drwtsn32.exe    ------         華生醫生顯示和配置管理 

dtcsetup.exe    ------         installs mdtc 

dvdplay.exe     ------         dvd播放 

dxdiag.exe      ------         direct-x診斷工具 

edlin.exe       ------         命令行的文本編輯器

edlin.exe       ------         命令行的文本編輯器

esentutl.exe    ------         ms資料庫工具 

eudcedit.exe    ------         type造字程式 

eventvwr.exe    ------         事件查看器 

evnt_cmd_.exe   ------         event to trap translator; configuration tool 

evntwin.exe     ------         event to trap translator setup 

exe2bin.exe     ------         轉換exe檔到二進位 

expand.exe      ------         解壓縮 

extrac32.exe    ------         解cab工具 

fastopen.exe    ------         快速訪問在記憶體中的硬碟檔 

faxcover.exe    ------         傳真封面編輯 

faxqueue.exe    ------         顯示傳真佇列 

faxsend.exe     ------         發送傳真嚮導 

faxsvc.exe      ------         啟動傳真服務 

fc.exe          ------         比較兩個檔的不同 

find.exe        ------         查找文件中的文本行 

findstr.exe     ------         查找文件中的行 

finger.exe      ------         一個用戶並顯示出統計結果 

fixmapi.exe     ------         修復mapi檔 

flattemp.exe    ------         允許或者禁用暫存檔案目錄 

fontview.exe    ------         顯示字體檔中的字體 

forcedos.exe    ------         forces a file to start in dos mode. 強制檔在dos模式下運行 

freecell.exe    ------         popular windows game 空當接龍 

ftp.exe         ------         file transfer protocol used to transfer files over a network connection 

gdi.exe         ------         graphic device interface 圖形介面驅動 

grovel.exe      ------         

grpconv.exe     ------         program manager group convertor 轉換程式管理員組 

help.exe        ------         displays help for windows 2000 commands 顯示幫助 

hostname.exe    ------         display hostname for machine. 顯示機器的hostname 

ie4uinit.exe    ------         ie5 user install tool ie5用戶安裝工具 

ieshwiz.exe     ------         customize folder wizard 自定義檔夾嚮導 

iexpress.exe    ------         create and setup packages for install 穿件安裝包 

iisreset.exe    ------         restart iis admin service 重啟iis服務 

internat.exe    ------         keyboard language indicator applet 鍵盤語言指示器 

ipconfig.exe    ------         windows 2000 ip configuration. 察看ip配置 

ipsecmon.exe    ------         ip security monitor ip安全監視器 

ipxroute.exe    ------         ipx routing and source routing control program ipx路由和源路由控制程式 

irftp.exe       ------         setup ftp for wireless communication 無線連接 

ismserv.exe     ------         intersite messaging service 安裝或者刪除service control manager中的服務 

jdbgmgr.exe     ------         microsoft debugger for java 4 java4的調試器 

jetconv.exe     ------         convert a jet engine database 轉換jet engine資料庫 

jetpack.exe     ------         compact jet database. 壓縮jet資料庫 

jview.exe       ------         command-line loader for java java的命令行裝載者 

krnl386.exe     ------         core component for windows 2000 2000的核心組件 

label.exe       ------         change label for drives 改變驅動器的標籤 

lcwiz.exe       ------         license compliance wizard for local or remote systems. 許可證符合嚮導 

ldifde.exe      ------         ldif cmd line manager ldif目錄交換命令行管理 

licmgr.exe      ------         terminal server license manager 終端服務許可協定管理 

lights.exe      ------         display connection status lights 顯示連接狀況 

llsmgr.exe      ------         windows 2000 license manager 2000許可協議管理 

llssrv.exe      ------         start the license server 啟動許可協定伺服器 

lnkstub.exe     ------         

locator.exe     ------         rpc locator 遠端定位 

lodctr.exe      ------         load perfmon counters 調用性能計數 

logoff.exe      ------         log current user off. 註銷用戶 

lpq.exe         ------       " display status of a remote lpd queue 顯示遠端的lpd列印佇列的狀態,顯示被送到基於unix的伺服器的列印任務 "

lpr.exe         ------         send a print job to a network printer. 重定向列印任務到網路中的印表機。通常用於unix客戶印表機將列印任務發送給連接了列印設備的nt的印表機伺服器。 

lsass.exe       ------         lsa executable and server dll 運行lsa和server的dll 

lserver.exe     ------         specifies the new dns domain for the default server 指定默認server新的dns域 

macfile.exe     ------         Used for managing MACFILES 管理MACFILES 

magnify.exe     ------         Used to magnify the current screen 放大鏡 

makecab.exe     ------         MS Cabinet Maker 製作CAB文件 

mdm.exe         ------         Machine Debug Manager 機器調試管理 

mem.exe         ------         Display current Memory stats 顯示記憶體狀態 

migpwd.exe      ------         Migrate passwords. 遷移密碼 

mmc.exe         ------         Microsoft Management Console 控制臺 

mnmsrvc.exe     ------         Netmeeting Remote Desktop Sharing NetMeeting遠程桌面共用 

mobsync.exe     ------         Manage Synchronization. 同步目錄管理器 

mountvol.exe    ------       " Creates, deletes, or lists a volume mount point. 創建、刪除或列出卷的裝入點。 "

mplay32.exe     ------         MS Media Player 媒體播放器 

mpnotify.exe    ------         Multiple Provider Notification application 多提供者通知應用程式 

mq1sync.exe     ------         

mqbkup.exe      ------         MS Message Queue Backup and Restore Utility 資訊佇列備份和恢復工具 

mqexchng.exe    ------         MSMQ Exchange Connector Setup 資訊佇列交換連接設置 

mqmig.exe       ------         MSMQ Migration Utility 資訊佇列遷移工具 

mqsvc.exe       ------         ? 

mrinfo.exe      ------         Multicast routing using SNMP 使用SNMP多點傳送路由 

mscdexnt.exe    ------         Installs MSCD (MS CD Extensions) 安裝MSCD 

msdtc.exe       ------         Dynamic Transaction Controller Console 動態事務處理控制臺 

msg.exe         ------         Send a message to a user local or remote. 發送消息到本地或遠端客戶 

mshta.exe       ------         HTML Application HOST HTML應用程式主機 

msiexec.exe     ------         Starts Windows Installer Program 開始Windows安裝程式 

mspaint.exe     ------         Microsoft Paint 畫板 

msswchx.exe     ------         

mstask.exe      ------         Task Schedule Program 任務計畫表程式 

mstinit.exe     ------         Task scheduler setup 任務計畫表安裝 

narrator.exe    ------         Program will allow you to have a narrator for reading. Microsoft講述人 

nbtstat.exe     ------         Displays protocol stats and current TCP/IP connections using NBT 使用 NBT(TCP/IP 上的 NetBIOS)顯示協定統計和當前 TCP/IP 連接。 

nddeapir.exe    ------         NDDE API Server side NDDE API伺服器端 

net.exe         ------         Net Utility 詳細用法看/? 

net1.exe        ------         Net Utility updated version from MS Net的升級版 

netdde.exe      ------         Network DDE will install itself into the background 安裝自己到後臺 

netsh.exe       ------         Creates a shell for network information 用於配置和監控 Windows 2000 命令行腳本介面。 

netstat.exe     ------         Displays current connections. 顯示協定統計和當前的 TCP/IP 網路連接。 

nlsfunc.exe     ------         Loads country-specific information 載入特定國家(地區)的資訊。 Windows 2000 和 MS-DOS 子系統不使用該命令。接受該命令只是為了與 MS-DOS 文件相容。 

notepad.exe     ------         Opens Windows 2000 Notepad 記事本 

nslookup.exe    ------         Displays information for DNS 該診斷工具顯示來自功能變數名稱系統 (DNS)名稱伺服器的資訊。 

ntbackup.exe    ------         Opens the NT Backup Utility 備份和故障修復工具 

ntbooks.exe     ------         Starts Windows Help Utility ?明 

ntdsutil.exe    ------         Performs DB maintenance of the ADSI 完成ADSI的DB的維護 

ntfrs.exe       ------         NT File Replication Service NT檔複製服務 

ntfrsupg.exe    ------         

ntkrnlpa.exe    ------         Kernel patch 核心補丁 

ntoskrnl.exe    ------         Core NT Kernel KT的核心 

ntsd.exe        ------         

ntvdm.exe       ------         Simulates a 16-bit Windows environment 模擬16位Windows環境 

nw16.exe        ------         Netware Redirector NetWare轉向器 

nwscript.exe    ------         runs netware scripts 運行Netware腳本 

odbcad32.exe    ------         ODBC 32-bit Administrator 32位ODBC管理 

odbcconf.exe    ------         Configure ODBC driver&#39;s and data source&#39;s from command line 命令行配置ODBC驅動和資料源 

os2.exe         ------         an os/2 warp server (os2 /o) os/2 

os2srv.exe      ------         an os/2 warp server os/2 

os2ss.exe       ------         an os/2 warp server os/2 

osk.exe         ------         on screen keyboard 螢幕鍵盤 

packager.exe    ------         windows 2000 packager manager 物件包裝程式 

pathping.exe    ------         combination of ping and tracert 包含ping和tracert的程式 

pax.exe         ------         PAX is a posix program and path names used as arguments must be specified in posix format. use ""//c/users/default"" instead of ""c:\users\default."" 啟動可?式存檔互換 (pax) 實用程式 "

pentnt.exe      ------         used to check the pentium for the floating point division error. 檢查pentium的浮點錯誤 

perfmon.exe     ------         starts windows performance monitor 性能監視器 

ping.exe        ------         packet internet groper 驗證與遠端電腦的連接 

posix.exe       ------         used for backward compatibility with unix 用於相容unix 

print.exe       ------         cmd line used to print files 列印文字檔案或顯示列印佇列的內容。 

progman.exe     ------         program manager 程式管理器 

proquota.exe    ------         profile quota program 

psxss.exe       ------         posix subsystem application posix子系統應用程式 

qappsrv.exe     ------         displays the available application terminal servers on the net work 在網路上顯示終端伺服器可用的程式 

qprocess.exe    ------         display information about processes local or remote 在本地或遠端顯示進程的資訊(需終端服務) 

query.exe       ------         query termserver user process and sessions 查詢進程和對話 

quser.exe       ------         display information about a user logged on 顯示用戶登陸的資訊(需終端服務) 

qwinsta.exe     ------         display information about terminal sessions. 顯示終端服務的資訊 

ras.exe         ------         starts a ras connection 運行ras連接 

rasautou.exe    ------         creates a ras connection 建立一個ras連接 

rasdial.exe     ------         dial a connection 撥號連接 

rcp.exe         ------         copies a file from and to a rcp service. 在 windows 2000 電腦和運行遠端外殼埠監控程序 rshd 的系統之間複製檔 

rdpclip.exe     ------         rdpclip allows you to copy and paste files between a terminal session and client console session. 再終端和本地複製和粘貼檔 

recover.exe     ------         recovers readable information from a bad or defective disk 從壞的或有缺陷的磁片中恢復可讀取的資訊。 

redir.exe       ------         starts the redirector service 運行重定向服務 

regedt32.exe    ------         32-bit register service 32位元註冊服務 

regini.exe      ------         modify registry permissions from within a script 用腳本修改註冊許可 

register.exe    ------         register a program so it can have special execution character istics. 註冊包含特殊運行字元的程式 

regsvc.exe      ------         

regsvr32.exe    ------         registers and unregister&#39;s dll&#39;s. as to how and where it register&#39;s them i dont know. 註冊和反註冊dll  

regtrace.exe    ------         options to tune debug options for applications failing to dump trace statements trace 設置 

regwiz.exe      ------         registration wizard 註冊嚮導 

remrras.exe     ------         

replace.exe     ------         replace files 用原始目錄中的同名檔替換目標目錄中的檔。 

reset.exe       ------         reset an active section 重置活動部分 

rexec.exe       ------         runs commands on remote hosts running the rexec service. 在運行rexec 服務的遠端電腦上運行命令。rexec 命令在執行指定命令前,驗證遠端電腦上的用戶名,只有安裝了 tcp/ip 協定後才可以使用該命令。 

risetup.exe     ------         starts the remote installation service wizard. 運行遠端安裝嚮導服務 

route.exe       ------         display or edit the current routing tables. 控制網路路由表 

routemon.exe    ------         no longer supported 不再支持了! 

router.exe      ------         router software that runs either on a dedicated dos or on an os/2 system. route軟體在 dos或者是os/2系統 

rsh.exe         ------         runs commands on remote hosts running the rsh service 在運行 rsh 服務的遠端電腦上運行命令 

rsm.exe         ------         mounts and configures remote system media 配置遠端系統媒體 

rsnotify.exe    ------         remote storage notification recall 遠端存儲通知回顯 

rsvp.exe        ------         resource reservation protocol 源預約協議 

runas.exe       ------         run a program as another user 允許用戶用其他許可權運行指定的工具和程式 

rundll32.exe    ------         launches a 32-bit dll program 啟動32位元dll程式 

runonce.exe     ------         causes a program to run during startup 運行程式再開始功能表中 

rwinsta.exe     ------         reset the session subsystem hardware and software to known initial values 重置會話子系統硬體和軟體到最初的值  

savedump.exe    ------         does not write to e:\winnt\user.dmp 不寫入user.dmp中 

scardsvr.exe    ------         smart card resource management server 子能卡資源管理伺服器 

schupgr.exe     ------         it will read the schema update files (.ldf files) and upgrade the schema. (part of adsi) 讀取計畫更新檔和更新計畫 

secedit.exe     ------         starts security editor help 自動安全性配置管理 

services.exe    ------         controls all the services 控制所有服務 

sethc.exe       ------         set high contrast - changes colours and display mode logoff to set it back to normal 設置高對比 

setreg.exe      ------         shows the software publishing state key values 顯示軟體發佈的國家語言 

setup.exe       ------         gui box prompts you to goto control panel to configure system components 安裝程式(轉到控制面板)

setver.exe      ------         set version for files 設置 ms-dos 子系統向程式報告的 ms-dos 版本號 

sfc.exe         ------         system file checker test and check system files for integrity 系統檔檢查 

sfmprint.exe    ------         print services for macintosh 列印macintosh服務 

sfmpsexe.exe    ------         

sfmsvc.exe      ------         

shadow.exe      ------         monitor another terminal services session. 監控另外一台中端伺服器會話 

share.exe       ------         windows 2000 和 ms-dos 子系統不使用該命令。接受該命令只是為了與 ms-dos 文件相容 

shmgrate.exe    ------         

shrpubw.exe     ------         create and share folders 建立和共用文件夾 

sigverif.exe    ------         file signature verification 文件簽名驗證 

skeys.exe       ------         serial keys utility 序列號製作工具 

smlogsvc.exe    ------         performance logs and alerts 性能日誌和警報 

smss.exe        ------         

sndrec32.exe    ------         starts the windows sound recorder 答錄機 

sndvol32.exe    ------         display the current volume information 顯示聲音控制資訊 

snmp.exe        ------         simple network management protocol used for network mangement 簡單網路管理協定 

snmptrap.exe    ------         utility used with snmp snmp工具 

sol.exe         ------         windows solitaire game 紙牌 

sort.exe        ------         compares files and folders 讀取輸入、排序資料並將結果寫到螢幕、檔和其他設備上 

SPOOLSV.EXE     ------         Part of the spooler service for printing 列印池服務的一部分 

sprestrt.exe    ------         

srvmgr.exe      ------         Starts the Windows Server Manager 伺服器管理器 

stimon.exe      ------         WDM StillImage- Monitor  

stisvc.exe      ------         WDM StillImage-  Service 

subst.exe       ------         Associates a path with a drive letter 將路徑與驅動器盤符關聯 

svchost.exe     ------         Svchost.exe is a generic host process name for services that are run from dynamic-link libraries (DLLs). DLL得主進程 

syncapp.exe     ------         Creates Windows Briefcase. 創建Windows文件包 

sysedit.exe     ------         Opens Editor for 4 system files 系統組態編輯程式 

syskey.exe      ------         Encrypt and secure system database NT帳號資料庫按群工具 

sysocmgr.exe    ------         Windows 2000 Setup 2000安裝程式 

systray.exe     ------         Starts the systray in the lower right corner. 在低許可權運行systray 

taskman.exe     ------         Task Manager 任務管理器 

taskmgr.exe     ------         Starts the Windows 2000 Task Manager 任務管理器 

tcmsetup.exe    ------         telephony client wizard 電話服務客戶安裝 

tcpsvcs.exe     ------         TCP Services TCP服務 

tftp.exe        ------         Trivial FTP 將檔傳輸到正在運行 TFTP 服務的遠端電腦或從正在運行TFTP 服務的遠端電腦傳輸檔 

tftpd.exe       ------         Trivial FTP Daemon 

themes.exe      ------         Change Windows Themes 桌面主題 

tlntadmn.exe    ------         Telnet Server Administrator Telnet服務管理 

tlntsess.exe    ------         Display the current Telnet Sessions 顯示目前的Telnet會話 

tlntsvr.exe     ------         Start the Telnet Server 開始Telnet服務 

tracert.exe     ------         Trace a route to display paths 該診斷實用程式將包含不同生存時間 (TTL) 值的 Internet 控制消息協定 (ICMP) 回顯資料包發送到目標,以決定到達目標採用的路由 

tsadmin.exe     ------         Terminal Server Administrator 終端服務管理器 

tscon.exe       ------         Attaches a user session to a terminal session. 粘貼用戶會話到終端對話 

tsdiscon.exe    ------         Disconnect a user from a terminal session 斷開終端服務的用戶 

tskill.exe      ------         Kill a Terminal server process 殺掉終端服務 

tsprof.exe      ------         Used with Terminal Server to query results. 用終端服務得出查詢結果 

tsshutdn.exe    ------         Shutdown the system 關閉系統 

unlodctr.exe    ------         Part of performance monitoring 性能監視器的一部分 

upg351db.exe    ------         Upgrade a jet database 升級Jet資料庫 

ups.exe         ------         UPS service UPS服務 

user.exe        ------         Core Windows Service Windows核心服務 

userinit.exe    ------         Part of the winlogon process Winlogon進程的一部分 

usrmgr.exe      ------         Start the windows user manager for domains 域用戶管理器 

utilman.exe     ------         This tool enables an administrator to designate which computers automatically open accessibility tools when Windows 2000 starts. 指定2000啟動時自動打開那台機器 

verifier.exe    ------         Driver Verifier Manager Driver Verifier Manager 

vwipxspx.exe    ------         Loads IPX/SPX VDM 調用IPX/SPX VDM 

w32tm.exe       ------         Windows Time Server 時間伺服器 

wextract.exe    ------         Used to extract windows files 解壓縮Windows檔 

winchat.exe     ------         Opens Windows Chat 打開Windows聊天 

winhlp32.exe    ------         Starts the Windows Help System 運行幫助系統 

winlogon.exe    ------         Used as part of the logon process. Logon進程的一部分 

winmine.exe     ------         windows Game 挖地雷 

winmsd.exe      ------         Windows Diagnostic utility 系統資訊 

wins.exe        ------         Wins Service Wins服務 

winspool.exe    ------         Print Routing 列印路由 

winver.exe      ------         Displays the current version of Windows 顯示Windows版本 

wizmgr.exe      ------         Starts Windows Administration Wizards Windows管理嚮導 

wjview.exe      ------         Command line loader for Java 命令行調用Java 

wowdeb.exe      ------         " . For starters, the 32-bit APIs require that the WOWDEB.EXE task runs in the target debugee&#39;s VM 啟動時,32位元API需要 "

wowexec.exe     ------         For running Windows over Windows Applications 在Windows應用程式上運行Windows 

wpnpinst.exe    ------         ? 

write.exe       ------         Starts MS Write Program 寫字板 

wscript.exe     ------         Windows Scripting Utility 腳本工具 

wupdmgr.exe     ------         Starts the Windows update Wizard (Internet) 運行Windows升級嚮導 

xcopy.exe       ------         複製檔和目錄,包括子目錄Win XP控制臺命令詳解 

正多面體座標產生器



public class 正多面體 {
  private static double r = 50;
  
  public static void main(String argv[]) {
    正四面體();
    正六面體();
    正八面體();
    正十二面體();
    正二十面體();
  }

  public static void printPoints(String s, Point3D[] v) {
    System.out.println(s);
    for(int i = 0; i < v.length; ++i) {
      System.out.println("p" + (i+1) + " " + v[i].x + " " + v[i].y + " " + v[i].z);
    }
  }
  
  public static void printLines(String s, int[][] o) {
    System.out.println(s);
    if(o == null) return;
    int c = 0;
    for(int i = 0; i < o.length; ++i) {
      for(int j = 0; j < o[i].length - 1; ++j) {
        System.out.println("l" + (c+1) + " p" + (o[i][j]+1) + " p" + (o[i][j+1]+1));
        c++;
      }
      System.out.println("l" + (c+1) + " p" + (o[i][o[i].length-1]+1) + " p" + (o[i][0]+1));
      c++;
    }
  }
  
  private static Point3D minus(Point3D p) {
    // TODO Auto-generated method stub
    return new Point3D(-p.x, -p.y, -p.z);
  }
  
  private static void 正四面體() {
    // TODO Auto-generated method stub
    double sq2 = Math.sqrt(2.0), sq3 = Math.sqrt(3.0); 
    Point3D[] Vt = new Point3D[4];
    Vt[0] = new Point3D(0, r, 0); 
    Vt[1] = new Point3D(0, -r/3, r*2*sq2/3); 
    Vt[2] = new Point3D(r*sq2/sq3, -r/3, -r*sq2/3); 
    Vt[3] = new Point3D(-r*sq2/sq3, -r/3, -r*sq2/3); 
     
    int[][] ord = {{0, 1, 2}, {0, 2, 3}, {0, 3, 1}, {1, 3, 2}};
    printPoints("正四面體", Vt);
    printLines("正四面體", ord);
  }

  
  
  private static void 正六面體() {
    // TODO Auto-generated method stub
    double sq2 = Math.sqrt(2.0), sq3 = Math.sqrt(3.0); 
    Point3D[] Vt = new Point3D[8];
    Vt[0] = new Point3D(0, r, 0); 
    Vt[1] = new Point3D(0, r/3, r*2*sq2/3); 
    Vt[2] = new Point3D(r*sq2/sq3, r/3, -r*sq2/3); 
    Vt[3] = new Point3D(-r*sq2/sq3, r/3, -r*sq2/3); 
     
    for(int i = 4; i < Vt.length; i++) 
        Vt[i] = minus(Vt[i-4]); 

    int[][] ord = {{0, 1, 7, 2}, {0, 2, 5, 3}, {0, 3, 6, 1}, 
                   {4, 6, 3, 5}, {4, 7, 1, 6}, {4, 5, 2, 7}}; 

    printPoints("正六面體", Vt);
    printLines("正六面體", ord);
  }

  private static void 正八面體() {
    // TODO Auto-generated method stub
    Point3D[] Vt = new Point3D[6];
    Vt[0] = new Point3D(0, r, 0); 
    Vt[1] = new Point3D(0, 0, r); 
    Vt[2] = new Point3D(r, 0, 0); 
     
    for(int i = 3; i < Vt.length; i++) 
        Vt[i] = minus(Vt[i-3]); 
     
    int[][] ord = {{0, 1, 2}, {0, 2, 4}, {0, 4, 5}, {0, 5, 1}, 
                   {3, 5, 4}, {3, 1, 5}, {3, 2, 1}, {3, 4, 2}};
    printPoints("正八面體", Vt);
    printLines("正八面體", ord);

  }

  private static void 正十二面體() {
    // TODO Auto-generated method stub
    double sq3=Math.sqrt(3.0),sq5=Math.sqrt(5.0);
    double t1 = (sq5+1)/2, t2 = (sq5-1)/2; 

    Point3D[] Vt = new Point3D[20];
    Vt[0] = new Point3D(0,r,0); 
    Vt[1] = new Point3D(0,r*sq5/3,r*2/3); 
    Vt[2] = new Point3D(r*sq3/3,r*sq5/3,-r/3); 
    Vt[3] = new Point3D(-r*sq3/3,r*sq5/3,-r/3); 
    Vt[4] = new Point3D(r*sq3/3,r/3,r*sq5/3); 
    Vt[5] = new Point3D(r*t1*sq3/3,r/3,r*t2*t2/3); 
    Vt[6] = new Point3D(r*t2*sq3/3,r/3,-r*t1*t1/3); 
    Vt[7] = new Point3D(-r*t2*sq3/3,r/3,-r*t1*t1/3); 
    Vt[8] = new Point3D(-r*t1*sq3/3,r/3,r*t2*t2/3); 
    Vt[9] = new Point3D(-r*sq3/3,r/3,r*sq5/3); 
    for(int i = 10; i < Vt.length; i++) 
        Vt[i] = minus(Vt[i-10]);
    
    
    int[][]ord = 
            {{ 0, 1, 4, 5, 2},{ 0, 2, 6, 7, 3},{ 0, 3, 8, 9, 1}, 
            { 1, 9,16,17, 4},{ 2, 5,18,19, 6},{ 3, 7,14,15, 8}, 
            {10,12,15,14,11},{10,13,17,16,12},{10,11,19,18,13}, 
            {11,14, 7, 6,19},{12,16, 9, 8,15},{13,18, 5, 4,17}};
    printPoints("正十二面體", Vt);
    printLines("正十二面體", ord);

  }

  private static void 正二十面體() {
    // TODO Auto-generated method stub
     double sq5=Math.sqrt(5.0); 
     double t1 = (sq5+1)/2, t2 = (sq5-1)/2; 
     Point3D[] Vt = new Point3D[12];
     Vt[0] = new Point3D(0,r,0); 
     Vt[1] = new Point3D(0,r/sq5,r*2/sq5); 
     Vt[2] = new Point3D(r*Math.sqrt(t1/sq5),r/sq5,r*t2/sq5); 
     Vt[3] = new Point3D(r*Math.sqrt(t2/sq5),r/sq5,-r*t1/sq5); 
     Vt[4] = new Point3D(-r*Math.sqrt(t2/sq5),r/sq5,-r*t1/sq5); 
     Vt[5] = new Point3D(-r*Math.sqrt(t1/sq5),r/sq5,r*t2/sq5); 
     for(int i = 6; i < Vt.length; i++) 
        Vt[i] = minus(Vt[i-6]); 
     
     int[][]ord = 
              {{0, 1,2},{0, 2,3},{0, 3,4},{ 0, 4, 5},{ 0,5, 1}, 
               {1,10,2},{2,11,3},{3, 7,4},{ 4, 8, 5},{ 5,9, 1}, 
               {6, 8,7},{6, 9,8},{6,10,9},{ 6,11,10},{ 6,7,11}, 
               {7, 8,4},{8, 9,5},{9,10,1},{10,11, 2},{11,7, 3}};
     printPoints("正二十面體", Vt);
     printLines("正二十面體", ord);

  }
  
  static class Point3D {
    public double x, y, z;
    public Point3D() {
      this.x = 0;
      this.y = 0;
      this.z = 0;
    }
    public Point3D(double x, double y, double z) {
      this.x = x;
      this.y = y;
      this.z = z;
    }
  }
}

2009年8月30日 星期日

Java Bézier Cubic Curve

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class CubicBezierCurve extends JFrame {

    private Point[] controlPoint = new Point[4];
    private Point[] curve = new Point[1024];
    private PaintPael paintPanel = null;
    private JLabel location = new JLabel("x: 0  y: 0");
    private static CubicBezierCurve cbc = null;
    private int controlPointCount = 0;
    public CubicBezierCurve() {
        for(int i = 0; i < controlPoint.length; ++i)
            controlPoint[i] = new Point(0, 0);
        InitComponent();
        setBackground(Color.WHITE);
        setSize(640, 480);
        setVisible(true);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }
    private void InitComponent() {
        setLayout(new BorderLayout());
        
        paintPanel = new PaintPael();
        
        add(paintPanel, BorderLayout.CENTER);
        
        Panel eastPanel = new Panel();
        eastPanel.setBackground(Color.BLACK);
        eastPanel.setLayout(new FlowLayout());
        Button restart = new Button("Restart");
        restart.addActionListener(new ButtonListener());
        
        
        eastPanel.add(restart);
        add(eastPanel, BorderLayout.EAST);
        location.setForeground(Color.RED);
        location.setBackground(Color.BLACK);
        add(location, BorderLayout.NORTH);
    }
    
    public Point BezierFunction(double t) {
      
      double tsqure = t * t;
      double tcubic = tsqure * t * t;

      double t1      = (1.0 - t);
      double t1square = t1 * t1; 
      double t1cubic = t1square * t1;
      
        double x = controlPoint[0].x * tcubic +
        3 * controlPoint[1].x * tsqure * t1 +
        3 * controlPoint[2].x * t * t1square+
        controlPoint[3].x * t1cubic;
        
        double y = controlPoint[0].y * t * t * t +
        3 * controlPoint[1].y * tsqure * t1 +
        3 * controlPoint[2].y * t * t1square+
        controlPoint[3].y * t1cubic;
            
        return new Point((int)x, (int)y);
    }
    public void ComputeCurve() {
        double t = 1.0 / 1024.0;
        for(int i = 0; i < curve.length; ++i) {
            curve[i] = BezierFunction(t * i);
        }
    }

    public static void main(String[] argv) {
        cbc = new CubicBezierCurve();
    }
   
    class PaintPael extends JPanel {

        public PaintPael() {
            PanelListener pl = new PanelListener();
            addMouseListener(pl);
            addMouseMotionListener(pl);
            setBackground(Color.BLACK);
        }
        public void paint(Graphics g) {
          super.paint(g);
            g.setClip(0, 0, getWidth(), getHeight());
            PaintControlPoint(g);
            PaintControlLine(g);
            PaintCurve(g);
        }
        private void PaintControlLine(Graphics g) {
            g.setColor(Color.green);
            if(controlPoint[0].x != 0 && controlPoint[0].y != 0 && controlPoint[1].x != 0 && controlPoint[1].y != 0)
                g.drawLine(controlPoint[0].x, controlPoint[0].y, controlPoint[1].x, controlPoint[1].y);
            if(controlPoint[1].x != 0 && controlPoint[1].y != 0 && controlPoint[2].x != 0 && controlPoint[2].y != 0)
                g.drawLine(controlPoint[1].x, controlPoint[1].y, controlPoint[2].x, controlPoint[2].y);
            if(controlPoint[2].x != 0 && controlPoint[2].y != 0 && controlPoint[3].x != 0 && controlPoint[3].y != 0)
                g.drawLine(controlPoint[2].x, controlPoint[2].y, controlPoint[3].x, controlPoint[3].y);
        }
        private void PaintControlPoint(Graphics g) {
            g.setColor(Color.BLUE);
            for(int i = 0; i < controlPoint.length; ++i) {
                if(controlPoint[i] != null && controlPoint[i].x != 0 && controlPoint[i].y != 0) {
                    g.fillOval(controlPoint[i].x - 2, controlPoint[i].y - 2, 4, 4);
                }
            }
        }
        private void PaintCurve(Graphics g) {
            if(curve[0] != null) {
                g.setColor(Color.RED);
                for(int i = 0; i < curve.length; ++i) {
                    g.fillOval(curve[i].x, curve[i].y, 2, 2);
                }
            }
        }
    }
    
    class ButtonListener implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            for(int i = 0; i < controlPoint.length; ++i) {
                if(controlPoint[i] != null) {
                    controlPoint[i].setLocation(0, 0);
                }
            }
            curve = null;
            curve = new Point[1024];
            //paintPanel.paintImmediately(0, 0, paintPanel.getWidth(), paintPanel.getHeight());
            controlPointCount = 0;
            cbc.repaint();
        }
    }
    
    class PanelListener extends MouseAdapter implements MouseMotionListener {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            for(int i = 0; i < controlPoint.length; ++i) {
                if(controlPoint[i] != null && controlPoint[i].x == 0 && controlPoint[i].y == 0) {
                    controlPoint[i].x = arg0.getX();
                    controlPoint[i].y = arg0.getY();
                    break;
                }
            }
            if(controlPoint[3].x != 0 && controlPoint[3].y != 0 && curve[0] == null) {
                cbc.ComputeCurve();
            }
            controlPointCount ++;
            cbc.repaint();

        }
        @Override
        public void mouseDragged(MouseEvent arg0) {
        }

        @Override
        public void mouseMoved(MouseEvent arg0) {
            location.setText("x: " + arg0.getX() + "  y: " + arg0.getX());
        }
    }
}

Java Quick Sort


public class JQuickSort {

  public static void main(String[] argv) {
    // JQuickSort qs = new JQuickSort(Integer.parseInt(argv[0]));
    JQuickSort qs = new JQuickSort(20);
    qs.start();
  }

  int[] a = null;

  public JQuickSort(int num) {
    a = new int[num];
    for (int i = 0; i < num; ++i) {
      int n = (int) (Math.random() 9999);
      a[i= n;
    }
  }

  int partition(int number[]int left, int right) {
    int i, j, s;
    s = number[right];
    i = left - 1;
    for (j = left; j < right; j++) {
      if (number[j<= s) {
        i++;
        int tmp = number[i];
        number[i= number[j];
        number[j= tmp;
      }
    }
    int tmp = number[i + 1];
    number[i + 1= number[right];
    number[right= tmp;
    return i + 1;
  }

  private void printArray() {
    System.out.print("Array: ");
    for (int i = 0; i < a.length; ++i) {
      System.out.print(a[i" ");
    }
    System.out.println();
  }

  void quicksort(int number[]int left, int right) {
    int q;

    if (left < right) {
      q = partition(number, left, right);
      quicksort(number, left, q - 1);
      quicksort(number, q + 1, right);
    }
  }

  private void start() {
    printArray();
    quicksort(a, 0, a.length - 1);
    printArray();
  }

}