前一陣子,因為不知該如何是好,一直詢問親友,卻猶豫不決,心情很煩悶。其實只有兩個選擇,做與不做而己。如果今天我不是當事人,而是旁人問我竟見,我當然可以斷然地告訴他答案--因為事不關已吧了!。
就是事關己,當然會躊躇不決,因為自已要承擔好與懷。所以我猜想,我是因為缺少磿練心志,學會提得起決定的後果,放得下一切得失,坦然面對一切。
畢竟這就是人生,人生無法重來,當時決定是好是壞,將來很難說,不過就是不要為了當初所做的決定而後悔。
2009年9月13日 星期日
quick sort
自己嚐試寫一下 quick sort,終於完成了,耶!。
花了不少的時間在debug,覺得很有成就感,也發現書上的範列寫的有問題,
沒有顧慮到一下特殊狀況,只有二個且是不用再排序的數列。
學演算法,真的動手寫,然後執行看看,才會發現結果與當初想的不一樣,
一邊分析問題,一邊DEbug,腦中想著"怎麼會這樣?", 終於找到原因,真是非常Happy.
花了不少的時間在debug,覺得很有成就感,也發現書上的範列寫的有問題,
沒有顧慮到一下特殊狀況,只有二個且是不用再排序的數列。
學演算法,真的動手寫,然後執行看看,才會發現結果與當初想的不一樣,
一邊分析問題,一邊DEbug,腦中想著"怎麼會這樣?", 終於找到原因,真是非常Happy.
#include"stdio.h"
#include
#define DEBUG 0
#define MAX 7
#include
void
QuickSort(
int *SortArray,
int LeftPosition,
int RightPosition
);
void
SwapInt
(
int *A,
int *B
);
int main(void){
int DataArray[MAX] ;
int i;
printf("before sort complete!\n");
srand(time(NULL));
for(i = 0; i < sizeof(DataArray)/sizeof(int); i++){
DataArray[i] = rand()% 100;
printf("DatatArray[%d] = %d \n",i,DataArray[i]);
}
QuickSort( DataArray,0,( sizeof(DataArray)/sizeof(int) )-1 );
printf("after sort complete!\n");
for(i = 0; i < sizeof(DataArray)/sizeof(int); i++){
printf("DatatArray[%d] = %d \n",i,DataArray[i]);
}
system("Pause");
return true;
}
void
QuickSort(
int *SortArray,
int LeftLimit,
int RightLimit
)
/*
*/
{
int CurtRight;
int CurtLeft;
//
// set the leftest as the pivot
//
if(LeftLimit < RightLimit){
CurtLeft = LeftLimit+1;
CurtRight = RightLimit;
do{
//
//find greater than pivot from left
//
while(CurtLeft < RightLimit && ( SortArray[CurtLeft] <= SortArray[LeftLimit] ) ){
CurtLeft++;
}//end for
//
//find smaller than SortArray[LeftLimit] or equal to it from right
//
while(CurtRight > LeftLimit && ( SortArray[CurtRight] > SortArray[LeftLimit] ) ){
CurtRight--;
}
//
//swap
//
#if DEBUG
printf("CurtLeft = %d ,SortArray[CurtLeft] = %d,CurtRight = %d ,SortArray[CurtRight] = %d\n"
,CurtLeft,SortArray[CurtLeft],CurtRight,SortArray[CurtRight]);
system("PAUSE");
#endif
if(CurtLeft < CurtRight){
SwapInt(&SortArray[CurtRight],&SortArray[CurtLeft]);
}
}while(CurtLeft < CurtRight);
//
// it means that SortArray[CurtRight] <= SortArray[Pivot] value
//
//swap it
//
SwapInt(&SortArray[CurtRight],&SortArray[LeftLimit]);
//
// see the CurtRight position as the middle position
// devide it into the two group and recursive it
//
//
#if DEBUG
int i;
printf("before sort complete!\n");
for(i = 0; i < MAX; i++){
printf("SortArray[%d] = %d \n",i,SortArray[i]);
}
system("Pause");
#endif
QuickSort(SortArray,LeftLimit,CurtRight-1);
QuickSort(SortArray,CurtRight+1,RightLimit);
}//end if(LeftLimit < RightLimit)
}
void
SwapInt
(
int *A,
int *B
)
{
int T;
T = *A;
*A = *B;
*B = T;
}
2008年12月16日 星期二
2008年6月18日 星期三
read news about "High school girls can take maternity leave "
I recently read the news about "High school girls can take maternity leave" on Taiwan news online.
This article says that the government will pass the new law which permit high school girl students
can take maternity leave ,and even if they is absent for one third of the semester ,can retake exams.But some people concern that this law will encourage pregnancy among the high school students.
In my opinion , it is theirs rights that can take maternity leave.If we worry about that may increase pregnancy among the high school, can teach them the aftereffect for the pregnancy .
Teach them to have responsibility.
This article says that the government will pass the new law which permit high school girl students
can take maternity leave ,and even if they is absent for one third of the semester ,can retake exams.But some people concern that this law will encourage pregnancy among the high school students.
In my opinion , it is theirs rights that can take maternity leave.If we worry about that may increase pregnancy among the high school, can teach them the aftereffect for the pregnancy .
Teach them to have responsibility.
2008年4月22日 星期二
改善記憶體常常不足--讓xp自動卸載DDL
最近工作用電腦的防毒軟體升級,結果常常造成,開機一段時間,系統會lag,重開機就會改善。
可是每次都重開機也是很麻煩,最後找到一個不錯方法,那就是讓xp自動把不使用的dll檔從記憶體中卸載。
方法為
開啟登錄檔編輯程式,在下列位址
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer
新增一個「AlwaysUnloadDLL」鍵值,類型為字元串值,值設為1,然後重開機就會生效。
快速方法,直接點擊下列網址,下載登錄檔。下載完畢,執行該檔,直接新增至登錄檔。
http://nouda.lin.googlepages.com/AutoUnloadDLL.reg
可是每次都重開機也是很麻煩,最後找到一個不錯方法,那就是讓xp自動把不使用的dll檔從記憶體中卸載。
方法為
開啟登錄檔編輯程式,在下列位址
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer
新增一個「AlwaysUnloadDLL」鍵值,類型為字元串值,值設為1,然後重開機就會生效。
快速方法,直接點擊下列網址,下載登錄檔。下載完畢,執行該檔,直接新增至登錄檔。
http://nouda.lin.googlepages.com/AutoUnloadDLL.reg
2008年4月20日 星期日
訂閱:
文章 (Atom)