2007年12月28日 星期五

OpenOffice使用雙引號(")

工具 -> 自動校正 -> 個人引號 -> 取消雙引號取代

2007年12月16日 星期日

Using MinGW with SciTE On a USB Stick

OS: Windows XP
Required Space: Less than 70 MB
Packages:

1. SciTE ( http://scintilla.sourceforge.net/SciTEDownload.html )
2. MinGW packages ( http://sourceforge.net/projects/mingw/ )
  • binutils
  • gcc-core
  • gcc-g++ ( optional in "MinGW GettingStart section" ?)
  • mingw-runtime
  • w32api
  • mingw-32 make ( optional )
  • mingw-utils ( optional )
Step 1 - Install MinGW on the USB Stick
  1. Create a directory for install (ex. MinGW )
  2. Extract All the MinGW packages into the directory (there is some strange instructions about " info/dir " in the Install MinGW page , but I ignore them , and still works fine )
Step 2 - Set Up SciTE properties
  1. Extract " SciTE.properties " from the full download version to the directory which stores source codes ( this properties will only take effect per directory, please refer to the comment inside )
  2. append following two lines to the SciTE.properties
command.compile.*.c=../PortableApps/MinGw/bin/gcc -o $(FileName).exe $(FileName).c -std=c99
command.go.*.c=./$(FileName).exe
" ../PortableApps/MinGw/ " is the directory where I install MinGW , as the graphic shown below,remember to change it according to your own condition



Final Step - Start Programming
  1. Use SciTE to open your source code , press Ctrl+F7 to compile (Or select it from Tools)
  2. Bang !! Now you can start programming on most computers :)

Reference:
Installing MinGW - manually
http://www.mingw.org/MinGWiki/index.php/Install%20MinGW
SciTE Documentation - properties file
http://scintilla.sourceforge.net/SciTEDoc.html


2007年11月24日 星期六

[轉貼]如果建築師必須如網頁設計師一般工作

如果建築師必須如網頁設計師一般工作

原著: 未知 翻譯: Ryan Wang (http://blog.pwang.com)

請設計和建造我的房子。我不太清楚我所需要的是什麼,所以你應該酌情衡量。我的房子應該大概有介於二至四十五間臥室之間。請確定在未來我可以輕鬆地 添加或刪除臥室。當你把建築藍圖帶給我看的時候,我才會決定什麼是我想要的。同時,估價的時候要給我各式各樣不同選項的價格表,使我可以看我高興挑選一 個。

記住,你要保證新造的房子成本比我現在住的這間還低,而且你必須改正目前存在於我現住房子的所有缺陷(我現在的房子經過廚房時地板會震動,而且牆壁太薄了沒辦法隔熱防寒)。

當你設計的時候,也特別記住我希望把每年的維修費用盡可能壓低。這意味著你該自行吸收額外材質的成本,如鋁合金,強化塑膠,或複合外牆。 (如果你選擇不用鋁合金,準備詳細解釋你為何這樣決定)。 拜託,建造的時候你要將最新潮的設計和最流行的材料搭配進去。我希望它是用最摩登的創意與點子所創造最時尚的建築作品。不過特別注意,設計廚房的時候記得 要把我祖母留給我的大同電冰箱考慮進去。

為了確保你將建造的房子適合我們全家人, 你必須聯絡我們家每一個小孩以及我的岳丈一家人。我的丈母娘會對房屋的設計很有意見因為她一年會來一次。

你要保證所有的衡量與抉擇是正確無誤的。但是,我仍有權推翻你所做的任何決定。

請你現在先不要用一些無關緊要的小細節打擾我。你的工作是為這個房屋制定總體規劃 - 做大事要想得深遠。舉例來說,在這個時候選擇地毯的顏色根本是無關緊要的。但是記住我老婆喜歡藍色。 同時,在這個時候先別擔心你要怎麼獲得興建房子的資源。你的首要工作是制定詳細的計劃和跟規格。但我預計當我一旦批准這些計劃, 兩天之內你會蓋好房子。

當你設計這房屋時特別給我記住,遲早我會賣給別人。因此,它應該有吸引各種各樣的潛在買家。 另外因為我住家附近的社區鄰居們都對房屋設計很挑剔,你必須保證他們喜歡我新房子的新奇特點。我建議你去看看我鄰居去年蓋的房子,我們超愛那間房屋的! 它有很多我們也想要放在新家的一些設施,例如那個奧運標準規格的游泳池。我相信你可以設計出這樣的新房子而不影響最終成本。

請準備一套完整的建築藍圖。在這個時候實在沒有必要做真正的設計,因為你其實只是在標這個案子而已。不過我事先先跟你說 - 如果我們改動設計而增加建築成本,你將會被追究責任。

你應該很高興能參與這項有趣的工程吧!你也知道,這種可以使用最新的技術和材料並自由自在的設計機會相當難得。 盡快完成整個企劃並且聯繫我!

PS :我的妻子剛剛告訴我,在這封信我給你的那麼多意見她不是很同意。作為建築師,你的責任是要解決這些意見分歧。我過去曾試過不過一直無法做到這一點。如果你不能處理好這件事情,我將不得不尋找另外的建築師。

PPS:也許我需要的不是一間房屋,而是旅行拖車。如果是這樣的話請盡快告訴我。其中最後一點應注意的是:要確保你的估價不超過六萬五千塊台幣。我有一個十五歲的侄子也會設計的房子,他說他可以用三萬兩千塊完成整個案子。

If Architects Had to Work Like Web Designers

Unknown
January 10, 2002

Please design and build me a house. I am not quite sure of what I need, so you should use your discretion. My house should have somewhere between two and forty-five bedrooms. Just make sure the plans are such that the bedrooms can be easily added or deleted. When you bring the blueprints to me, I will make the final decision of what I want. Also, bring me the cost breakdown for each configuration so that I can arbitrarily pick one.

Keep in mind that the house I ultimately choose must cost less than the one I am currently living in. Make sure, however, that you correct all the deficiencies that exist in my current house (the floor of my kitchen vibrates when I walk across it, and the walls don’t have nearly enough insulation in them).

As you design, also keep in mind that I want to keep yearly maintenance costs as low as possible. This should mean the incorporation of extra-cost features like aluminum, vinyl, or composite siding. (If you choose not to specify aluminum, be prepared to explain your decision in detail.)

Please take care that modern design practices and the latest materials are used in construction of the house, as I want it to be a showplace for the most up-to-date ideas and methods. Be alerted, however, that kitchen should be designed to accommodate, among other things, my 1952 Gibson refrigerator.

To insure that you are building the correct house for our entire family, make certain that you contact each of our children, and also our in-laws. My mother-in-law will have very strong feelings about how the house should be designed, since she visits us at least once a year.

Make sure that you weigh all of these options carefully and come to the right decision. I, however, retain the right to overrule any choices that you make.

Please don’t bother me with small details right now. Your job is to develop the overall plans for the house: Get the big picture. At this time, for example, it is not appropriate to be choosing the color of the carpet. However, keep in mind that my wife likes blue.

Also, do not worry at this time about acquiring the resources to build the house itself. Your first priority is to develop detailed plans and specifications. Once I approve these plans, however, I would expect the house to be under roof within 48 hours.

While you are designing this house specifically for me, keep in mind that sooner or later I will have to sell it to someone else. It therefore should have appeal to a wide variety of potential buyers.

Please make sure before you finalize the plans that there is a consensus of the population in my area that they like the features this house has. I advise you to run up and look at my neighbor’s house that he constructed last year. We like it a great deal. It has many features that we would also like in our new home, particularly the 75-foot swimming pool. With careful engineering, I believe that you can design this into our new house without impacting the final cost.

Please prepare a complete set of blueprints. It is not necessary at this time to do the real design, since they will be used only for construction bids. Be advised, however, that you will be held accountable for any increase of construction costs as a result of later design changes.

You must be thrilled to be working on as an interesting project as this! To be able to use the latest techniques and materials and to be given such freedom in your designs is something that can’t happen very often.

Contact me as soon as possible with your complete ideas and plans.

PS: My wife has just told me that she disagrees with many of the instructions I’ve given you in this letter. As architect, it is your responsibility to resolve these differences. I have tried in the past and have been unable to accomplish this. If you can’t handle this responsibility, I will have to find another architect.

PPS: Perhaps what I need is not a house at all, but a travel trailer. Please advise me as soon as possible if this is the case. One last note, make sure your estimate for this plan is no more than $2000. I have a 15 year old nephew who designs houses and he say he can build it for me for $1000.”

2007年10月5日 星期五

96學年度成大資訊所與醫資所碩士入學考參考書目

今年可能也差不多,感覺是讀不完,考好玩的吧 :)

http://www.csie.ncku.edu.tw/announce/960126/960126.htm
 
線性代數
Steven J. Leon:Linear Algebra with Applications,6th Edition.
Fraleigh & Beauregard:Linear Algebra,3rd Edition.

離散數學
Ralph P. Grimaldi:Discrete and Combinatorial Mathematics,4th Edition.
C.L. Liu:Elements of Discrete Mathematics,2nd Edition.

演算法
T. H. Cormen,C. E. Leiserson, R. L. Rivest, and C. Stein,Introduction to Algorithms,Second Edition.

資料結構
Horowitz & Sahni:Fundamentals of Data Structures.

計算機組織
D. A. Patterson and J. L. Hennessy,Computer Organization and Design,3rd Edition,Morgan Kaufmann.

作業系統
Silberschatz and P. Galvin:Operating System Concepts,7th Edition,Addison-Wesley.

機率統計
Ronald E. Walpole, et al., Probability & Statistics for Engineers & Scientists ,Seventh Edition(2002出版).
Richard A. Johnson,Miller & Freund's Probability and Statistics for Engineers,7th Edition(2005出版).

2007年8月19日 星期日

qsort運用(II)

以下範例是將一個 integer 陣列做 qsort:
int compare(const void *pa,const void *pb);

int main(){
qsort(diff,num-1,sizeof(int),compare);
}

int compare(const void *pa,const void *pb){
int a,b;
a=*(int *)pa;
b=*(int *)pb;
if(a < b)
return -1;
}
else if(a==b){
return 0;
}
else{
return 1;
}
}
qsort限制比較函式中,所傳參數必須為(const void *, const void*)也就是一個 void 指標,在 compare 函式中,不能直接拿*pa和*pb來作比較,會出現有關void的blabla...錯誤,因此必須轉為其他型態,先以(int *)強制轉型為 int 指標,再利用 * 運算子來存取儲存於其中的 integer,便可成功編譯。

2007年8月6日 星期一

Using long long with MinGW

long long是 C99的標準,可以處理-((2^63)-1)~(2^63)-1的數字,正常使用方法是 %lld /u/x,但如果使用MinGW來編譯的話,必須用%I64d /u/x 才能正常使用

The printf() implementation used by MinGW (which is provided by msvcrt.dll) uses its own format specifier for 64-bit integers as documented in MSDN: http://msdn.microsoft.com/library/en-us/vccore98/HTML/_crt_size_and_distance_specification.asp. For example, %I64d will format a (decimal) long long and %I64u will format an unsigned long long.

參考資料:http://www.mingw.org/MinGWiki/index.php/long%20long

2007年7月31日 星期二

832 Financial Risk

題目網頁:http://acm.uva.es/p/v8/832.html

這是我目前做過最心機的題目了,重點在於最後幾句
Your program must write the percentage of uncovered risk, truncated to 2 fractional digits.
原本以為用 %.2lf%% 就可以解決,上傳了10幾遍還是沒辦法,靈機一動才想到這幾句話的意思...

有可能的Output: 30%、11.85%、10.6%

2007年7月25日 星期三

利用 Filezilla 連接 SFTP

使用環境:Windows+Filezilla Portable(隨身碟)
  1. 進入Filezilla的站台管理員,新增一站台,輸入主機名稱(port會自行調整),伺服器型態選擇 "SFTP使用SSH2"輸入 使用者名稱 與 Account ,即可連線。
  2. 利用之前不需輸入帳號密碼便可登入SSH做出來的Key,首先到Putty作者的網頁下載Pageant,執行後,畫面右下角會出現Pageant的圖示,選擇 add key 匯入之前的.ppk檔,輸入passphrase,連線後Filezilla一樣會跳出要求密碼的視窗,再次輸入passphrase,即可登入。

參考資料:
http://filezilla-project.org/wiki/index.php/Howto

2007年7月24日 星期二

一些有關 C 語言的連結

C Standard Library:
http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html

裡面包含了C99才加入的lib,不過說明比較少,平常用的話,我比較喜歡 Eric Huss 1997年寫的

The C Reference Guide:
http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

雖然是比較舊的版本,但是說明比較詳細,有些還會附範例,我直接存到電腦裡,要寫的時候直接開起來看。

FAQ:

http://c-faq.com/

Infrequently Asked Question:
http://www.plethora.net/~seebs/faqs/c-iaq.html


裡面有些問題還挺有趣的,平時不會想到,有空可以研究研究。

2007年7月11日 星期三

Uniform Server

Introduction
The Uniform Server is a WAMP package that allows you to run a server on any MS Windows OS based computer. It is small and mobile to download or move around and can also be used or setup as a production/live server. Developers also use The Uniform Server to test their applications made with either PHP, MySQL, Perl, or the Apache HTTPd Server.

官方網站
文件

目前最新版本:Uniform Server 3.5-Apollo

安裝後,phpmyadmin沒辦法使用,說啥
Cannot load mysqli extension. Please check your PHP configuration.

找了一堆討論看不出重點,就不管了,反正用console可以連的上就好,順便練習SQL語言,console連線方法在文件裡有講到。


7/16
知道問題出在哪邊了:之前自己安裝php和mysql的時候,把libmysql.dll自己複製到C:\windows下面,砍掉以後就一切正常,不然php根本沒辦法支援mysql...
以前還寫啥教學文章,現在看看真是膚淺...

2007年6月29日 星期五

vim 設定

~/.vimrc

1 :syntax on
2 :set cindent
3 :set autoindent
4 :set nu
5 :set fdm=indent

在家裡因為螢幕比較小,一般tab是8個空白字元,可能沒幾個迴圈就必須縮行,這時可以設定按tab鍵是送出自己設定的空白字元數,這樣就算以後別的編輯器要開啟這個檔案也不會有問題

:set shiftwidth=4
:set softtabstop=4

參考資料:
www.study-area.org/tips/vim/Vim-9.html

2007年6月17日 星期日

Cygwin安裝OpenSSH

Cygwin安裝:
Admin:cygrunsrv
Net:openssh

進入Cygwin shell:

ssh-host-config
Should privilege separation be used? (yes/no) yes

Warning: The following function requires administrator privileges!
Should this script create a local user 'sshd' on this machine? (yes/no) yes

Do you want to install sshd as service?
(Say "no" if it's already installed as service) (yes/no) yes

Which value should the environment variable CYGWIN have when
sshd starts? It's recommended to set at least "ntsec" to be
able to change user context without password.
Default is "ntsec". CYGWIN= 按下Enter接受預設

讓sshd服務不隨開機而啟動:
執行-> services.msc -> 找到 CYGWIN sshd -> 設定為手動啟動

手動開啟:
cygrunsrv -S sshd

參考網址:
cha.homeip.net/blog/archives/2006/04/_winxp_cygwin_s.html

2007年6月8日 星期五

qsort與struct指標運用

  1. qsort是stdlib.h裡所包含的一個函式,宣告方式請看參考資料一,qsort需要傳入四個參數,值得一提的是第三和第四個參數,第三個參數是資料型態的大小,可以用sizeof()傳進去比較好,不必手算,第四個參數是比較的函式,要求宣告方式為 int compare(const void *,const void *),傳進的參數必須為void型態,且為const,其他程式無法修改,因此必須在傳進compare後另外宣告兩個原本型態之指標 a與b,再將參數強制轉型指定給 a和b 才能使用,可以看下面的範例程式碼與參考資料中的"函數當作函數的參數"會比較容易瞭解
  2. 若宣告一個 struct abc後,想存取其中的元素時,必須用"."運算子,但如果是 struct 的指標的話,則必須使用"->"來存取裡面的元素,請看參考資料中的pointer
範例程式碼
#include <stdlib.h>

int cmplength(const void *pa,const void *pb);
/*宣告cmplength()*/

struct dics{
char word[26];
int order;
int neworder;
}dictionary[10000];
/*定義srtuct dics並宣告dictionary[10000]為 dic 型態*/

int main(){
qsort(dictionary,N,sizeof(struct dics),cmplength);
return 0;
}
/*呼叫qsort*/

int cmplength(const void *pa,const void *pb){
int la,lb,result;
struct dics *a=(struct dics *)pa;
struct dics *b=(struct dics *)pb;

la=strlen(a->word);
lb=strlen(b->word);
if(la < lb ){
return -1;
}
else{
return 1;
}
}

參考資料


The Clibrary Reference Guide :
qsort-
www.acm.uiuc.edu/webmonkeys/book/c_guide/2.13.html#qsort

pointer-
www.acm.uiuc.edu/webmonkeys/book/c_guide/1.4.html

函數當作函數的參數:
libai.math.ncu.edu.tw/bcc16/C/C/d0.shtml

2007年6月7日 星期四

Pietty細部設定

連回自己電腦上OpenSSH Server時的一些設定

Vim內使用Backspace:
Terminal-
Keyboard->The Backspace Key:選擇 Control+H

使用右手邊之數字鍵:
Terminal-
Features-> disable application keypad mode

字體:
Window-
Apperance->Font:@Dotumche 16-point 或 Courier New 16-point

顏色顯示:(註解顏色太深看不清楚)
Window-
Colours->ANSI Blue->Modify

游標:
Window-
Apperance->Adjust the use of the cursor ->Underline


參考資料
my.opera.com/render/blog/show.dml/166886?cid=2447131

2007年6月6日 星期三

不需輸入帳號密碼便可登入SSH

SSH Server:Windows+Cygwin OpenSSH
Client:Portable Putty(0.59) (隨身碟)

在Server上先輸入 ssh-keygen -t rsa
並設定好大於四個字元的 passphrase (也可空白)

產生金鑰後,到 ~/.ssh 裡,輸入 cat id_rsa.pub >> authorized_keys
便完成 Server 部份的設置(註一),接著把 id_rsa 抓回自己電腦
利用Putty作者寫的Puttygen讀取 id_rsa ,確認完 passphrase 後,
存為 private key

開啟Putty,在 SSH->Auth ,選擇剛剛的 private key
接著輸入Server位址,SSH連線

連上後,會要求輸入登入帳號
接著輸入
passphrase 即可。(註二)


有一點要提的是--不要直接利用Puttygen產生金鑰,我就是照作者網頁上的指示去試,結果浪費我將近兩個小時...



註一:不同設定和Server時,檔案存放位置可能是在~/.ssh2,或認證金鑰檔的名稱不同

註二:若當初 passphrase 設空白,則輸入帳號後便直接登入,我是考慮到隨身碟遺失,以及怕外面電腦上有keystoke logger,不想把本機密碼洩漏,才設 passphrase

參考資料:

鳥哥的私房菜
linux.vbird.org/linux_server/0310telnetssh.php

Jamyy's Blog
cha.homeip.net/blog/archives/2006/04/_winxp_cygwin_s.html

Using public keys for SSH authentication
the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter8.html#pubkey-puttygen

2007年5月31日 星期四

[轉貼]不同機型用Ghost複製XP,而且不必封裝

作者:(MyChat 數位男女)fatball


有大大在問關於 Ghost 複製 XP 的問題,我想同機型機器間複製應該是沒問題的,但不同機型間的複製可是問題多多喔,我已經找出解決方案,而且完成許多電腦的複製,我把方法 post 出來大家參考。


如果機型一模一樣,可以用 Ghost 做成映像檔,用那個映像檔可以重灌所有的同機型電腦,沒問題的。
我們學校高達 82 台同機型電腦就是這樣安裝起來的啊!當然有幾點要注意:

1.如果沒有登入網域的問題,重灌完成後改電腦名稱就可以了。

2.如果電腦要登入網域,重灌完第一次開機要先拔除網路線,待改完電腦名稱後再重新接上網路線,進行其他群組與加入網域的設定。

或許有人會問:
同機型電腦比較簡單,如果不同機型呢?
一樣可以用 Ghost 複製 XP,而且不必封裝喔!我在學校已經實驗成功了,學校內高達10多種不同機型都安裝了同一版本的XP

準備工作如下:
1.用來做映像檔的電腦必須用原始安裝方式安裝的(也就是不能拿封裝過的 XP 來用),就累這麼一次。

2.準備被重灌電腦的驅動程式(可以先下載放在 D 碟中)

3.確定兩部電腦的系統磁碟分割區一樣大(最好是這樣啦,比較不會出問題,反正安裝完還可以再調整啊!)

4.確定要重灌那台電腦的電源管理模式,從裝置管理員那裡查詢電腦選項,可以看到(有標準PC,ACPI PC,ACPI uniprocessor PC,ACPI Multiprocessor PC,MPS uniprocessor PC,MPS Multiprocessor PC)。這項一定要選對,否則重灌完會無法開機的。

5.準備一支 PS2 滑鼠(因為等一下會砍除 USB 驅動程式)。

正式開始:
1.先將原電腦以磁片(或開機光碟或USB開機碟)開機後,用 Ghost 將系統碟備份一份到D碟中,以免後面程序錯誤導致系統毀損,那就完了。

2.完成備份後,原電腦正常開機。打開裝置管理員依序刪除以下驅動程式(如遇到電腦說要重新開機,千萬不要重開):音效卡→網路卡→USB驅動程式(如果有很多個,請依序刪除)→顯示卡(這裡會要你重開機,千萬不要重開喔)。

3.將裝置管理員→IDE ATA/ATAPI控制器打開,對名字最長的那個按滑鼠右鍵→選擇更新驅動程式→不要選自動安裝→選擇自行安裝→顯示相容硬體→選擇標準雙通道PCI IDE控制器

4.將置管理員→電腦打開→選擇更新驅動程式→不要選自動安裝→選擇自行安裝→顯示相容硬體→選擇要重灌電腦那台的電源管理模式(一定要選對!一般而言,2003年以後生產的機器多為ACPI uniprocessor PC,之前生產的則有不一樣的設定,切記!)

5.正常關機。

6.若要硬碟對硬碟複製,則需開機殼,將要重灌的硬碟接上來,Ghost 選擇 partition to partition。你也可以直接將系統碟備份成映像檔,然後再用其他方式(如網芳的方式傳到要重灌那台電腦的硬碟後再去做 Ghost 還原)。

7.將原電腦以磁片(或開機光碟或 USB 開機碟)開機後,用 Ghost 將剛剛備份的映像檔還原回來,讓原電腦恢復正常。

8.要重灌的電腦照第7步驟的方式用 Ghost 還原映像檔(如果在第6步驟時是選擇 partition to partition,可以直接開機)。開機後電腦應會重找驅動程式,這時會需要你安裝一些這台電腦所需的驅動程式→通常會重開個2~3次,確定安裝完成 後,選擇關機,如果可以正常關閉電腦表示你成功了。如果不能正常關機表示你的電源管理模式選擇錯誤了,你必須重來一次了。

說真的,過程粉累 ,我打字也粉累。

本來當作私有密技(群校只有我一個人會,其他人只是聽說我是這樣做,但沒實際動手做過),但我還是分享給大家知道。

我目前每個電源管裡模式都製作了一份專有 Ghost 映像檔,沒辦法學校裡的機型太多了,要我每一種機型就重頭灌一次XP,我不瘋了才怪。

目前用 IBM 的 A50 機型成功移植到 LEO 兩種機型(都是微星主機板),三種 ASUS 主機板以及一些雜牌電腦。
至於我自己個人電腦則是用為星主機板的 AMD Duran 1.7 移植到HP筆記型電腦,目前使用正常。

我參考網路上的萬能複製法,但屢試屢敗,花了半年才發展出這套程序,希望可以造福大家

2007年5月10日 星期四

11029 Leading and Trailing

題目網頁

問題:
給定三數字,T代表Case數目(T<1001),n為底(32bit integer),
k則為指數(k<10000001),求nk的前三位與後三位數字(中間以'...'分隔)。

解法:
利用對數來計算前三位,mod 1000取得後三位

應注意部份:
使用scanf()時使用 %lf 才可吃到 double
瞭解 double 與 interger 可存數值上限,並小心別 Overflow

使用到之特殊函數:
log10(),floor(),pow()

ps.如果助教看到這篇的話,不要以為是抄襲啊,我是有修課的學生啊,可以比對一下帳號 :)

2007年5月9日 星期三

double 型態 使用 mod 運算子

會出現錯誤,因為 mod 是取餘數(註一)

而 double 因為有小數點,只要是有理數的話,都可以 double 表示

所以一運算之下,結果沒有餘數,因此 gcc 預設會出現錯誤訊息。


本來想用 floor( )這個函數加上一些運算來代替這功能,

但floor( )只能回傳 largest interger value

所以 傳入floor( ) 的值也不能太大...

就算是unsigned long interger 也只大約 4*10^9

比起 double 可到 10^308 可說是小到不行啊...




註一:Wikipedia:Modulo_operation

2007年4月28日 星期六

Openoffice行高單位設定

版本:2.0

工具 -> 選項 -> Openoffice.Writer -> 一般

將 "公分" 改為 "點"

ps. 1 pt = 0.035 cm

Openoffice上下標快速鍵

版本:2.0

上標:Ctrl + Shift+ p

下標:Ctrl + Shift + b

2007年4月19日 星期四

God Of War II Trailer





Demo


接下來是光頭男盪鞦韆?

God of War Trailer



2005年的遊戲,影片中介紹了大概的背景和故事劇情發展

但還是別忘了,遊戲目的是訓練玩家走獨木橋的平衡感

God of War Music Video



不要被影片騙了,這是一塊光頭肌肉男走獨木橋的遊戲!

2007年3月29日 星期四

Quantum Fireball

今天閒晃,剛好看到Tom's Hareware Guide的一篇介紹硬碟歷史的文章

看到Quantum Fireball,好懷念啊,雖然我們家的硬碟容量是20GB,但外表一模一樣,那顆硬碟已經在上學期壽終正寢,從我高一用到現在,經歷過FlashGet續傳下載時期,每秒十幾kb的下載速度(甚至個位數),為了抓個6、7百mb的遊戲,電腦可能要開個幾天幾夜不關,到後來的P2P時代,eDonkey2000,eMule,最後幾個月也撐過BT考驗,直到某天開機突然出現"磁區可能損毀,請儘速備份",等到我買回新硬碟將資料複製過去才退下戰場,實在是鞠躬盡瘁,死而後已啊!


目前屍體放在家裏的某個儲藏箱內,依然可以正常開機,只是BIOS跑時會出現警告訊息就是這樣,我特地上網想找找有沒有程式可以修復,才發現Quanturn早已被併購,官方網站消失的無影無蹤,雖然試了幾個不同程式,依然無效,最後為了保險,還是拆了下來,留待以後解剖。


不過家裏電腦自從去年某天燒掉,我又不在家,送去給別人修以後,就有莫名其妙的問題出現,還挺煩人的啊...

2007年3月28日 星期三

Big-O Opening Song - Big-O!

完整版聽起來超熱血!

Big-O Ending Song - And forever

Singer:Robbie Danzie
Naoki Takao


scanf(" ") - 貳

程式碼貳:
#include <stdio.h>

int main(void)
{
int n=0;
char string[3];

printf("Please input:\n");


scanf("%c ",&string[0]);
/*%c後面有空白*/
scanf("%c",&string[1]);

for(n=0;n<3;n++){
printf("(%d)%c ",n,string[n]);
}

system("PAUSE");
return 0;
}

跑這個程式,兩行scanf()的效果等於scanf("%c %c")
程式會把stdin的資料暫存起來,直到另一段程式碼向它要求input

如果中間加上另一格式的輸入呢?




程式碼參:
#include <stdio.h>

int main(void)
{
int n=0,a;
char string[3];

printf("Please input:\n");


scanf("%c ",&string[0]);
scanf("%d",&a);
/*抓interger*/
scanf("%c %c",&string[1],&string[2]);

for(n=0;n<3;n++){
printf("(%d)%c ",n,string[n]);
}
printf(" a:%d",a);

system("PAUSE");
return 0;
}


Case1:
  • 輸入:a_c_12
  • 輸出:(0)a (1)c (2)1 a:1628696576
Case2:
  • 輸入:a_12_c
  • 輸出:(0)a (1) (2)c a:12
Case3:
  • 輸入:12_a_c
  • 輸出:(0)1 (1) (2)a a:2

scanf(" ") - 壹

之前在mis99板看到助教討論 scanf() 內加上空白之功用,覺得還挺有趣的,自己也來玩玩看,

程式碼壹:
#include <stdio.h>

int main(void)
{
int n=0;
char string[3];

printf("Please input:\n");

scanf("%c %c %c",&string[0],&string[1],&string[2]);
/*%c之間有空白' '*/
for(n=0;n<3;n++){
printf("(%d)%c ",n,string[n]);
}

system("PAUSE");
return 0;
}

Case1:
  • 輸入:abc
  • 輸出:(0)a (1)b (2)c
Case2:
  • 輸入:_a_b_c ( _代表空白 )
  • 輸出:(0) (1)a (2)b
Case3:
  • 輸入:a_______b____c
  • 輸出:(0)a (1)b (2)c
Case4:
  • 輸入:a___ (按enter跳行)
____b
______c
  • 輸出:(0)a (1)b (2)c

因此可以得知,scanf("")內加上空白代表跳過輸入進來的空白字元(whitespace)

直到碰上下一個輸入,Case2中,scanf()首先取得了一個空白字元,並存入陣列內,接

下來便忽略剩餘部分,直到碰上b,c

電腦加速

可以參考Tom's Hardware這篇

2007年3月7日 星期三

為了作業

沒辦法,搞個Blog
應該想到才會更新吧 XDD~