Wednesday, October 14, 2009

MS-DOS指令說明

以下列出一些常用的DOS指令

DIR指令

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename]
指定要顯示的磁碟機、目錄或檔案。

/A 依照指定的檔案屬性來顯示檔案。
attributes D 目錄 R 唯讀檔
H 隱藏檔 A 保存檔
S 系統檔案 - 無意義
L 重新分析點 - 首碼表示否定
/B 使用單純格式 (沒有標頭資訊或摘要)。
/C 顯示檔案大小千位數分隔符號。這是預設值。使用 /-C 來停用
分隔符號的顯示。
/D 與寬的列表格式相同,但是依照欄來排序。
/L 使用小寫顯示。
/N 使用新的長列表格式,檔名會顯示在最右方。
/O 依照指定的排序順序來列出檔案。
sortorder N 依名稱 (英文字母) S 依大小 (最小的在前)
E 依副檔名 (英文字母) D 依照日期與時間 (日期較早的在前)
G 先列出子目錄 - 表示相反的順序
/P 當資料填滿整個螢幕時暫停顯示。
/Q 顯示檔案擁有者。
/R 顯示檔案的替代資料流。
/S 顯示指定目錄及所有子目錄中的檔案。
/T 指定用來顯示或排序的時間欄位
timefield C 建立
A 上次檔案存取時間
W 上次寫入檔案時間
/W 使用寬的列表格式。
/X 顯示對非 8.3 格式的檔案產生的短檔名。這個格式和 /N 相同,
但是短檔名會插入在長檔名之前。如果沒有長檔名存在,該處會
顯示空白。
/4 顯示四位數的年份

參數可能會在 DIRCMD 環境變數預先設定。您可以在任何參數使用連字號字首(-)
來覆蓋預先的設定--例如: /-W。

Saturday, September 26, 2009

線上免費下載

在做網頁時,常常需要很多按鈕圖片,如果平常沒有做好蒐集的工作,往往在要用的時候找不到好用的愛紐圖片。

如果你有以上問題可以到 http://365icon.com/ 這個網站來尋寶。除了圖資豐富外,畫質都相當不錯喔!

寄件者 Blogger
我就挑選很懷舊的"瑪莉歐"的套圖吧!


寄件者 Blogger
這些圖片質感都很不錯,真是個值得推薦的好網站!


寄件者 Blogger

線上免費下載ICON圖檔的網站

常常會有以下問題:
  1. 總覺得自己桌面的icon很醜。
  2. 當使用RocketDock等工具時,icon放大影像都會模糊掉。
  3. 線上下載的套裝icon沒有提供所有應用程式的套圖,總覺得有點缺憾。
如果你有以上的問題,那你可以到http://www.iconfinder.net/找尋你喜歡的icon囉!

寄件者 Blogger
哇! 好多豐富的icon啊! 快去用用看吧!

寄件者 Blogger

Wednesday, September 23, 2009

數字系統(十進制轉二、八、十六進制)

很久沒練習了C的語法了,心血來潮就寫了這篇。

BinarySystem()是將二進制數字轉換成十進制
第13行:Bin[i]-48是因為Bin是字元(char),所以要透過ASCII(美國資訊交換標準碼)轉換成數字。

#include<iostream>
#include<conio.h>
void BinarySystem(){
char Bin[11];
int LastDigit=0;
int Decimal=0, Weight=1;
printf("請輸入二進制數字(最多10位元):");
scanf("%s", Bin);
while(Bin[LastDigit]!='\0')
LastDigit++;
LastDigit--;
for(int i=LastDigit; i>=0; i--){
Decimal=Decimal+(Bin[i]-48)*Weight;
Weight*=2;
}
printf("二進制數字:%s\n十進制數字:%d\n", Bin, Decimal);
}

OctalSystem()是將八進制數字轉換成十進制

void OctalSystem(){
char Bin[11];
int LastDigit=0;
int Decimal=0, Weight=1;
printf("請輸入八進制數字(最多10位元):");
scanf("%s", Bin);
while(Bin[LastDigit]!='\0')
LastDigit++;
LastDigit--;
for(int i=LastDigit; i>=0; i--){
Decimal=Decimal+(Bin[i]-48)*Weight;
Weight*=8;
}
printf("八進制數字:%s\n十進制數字:%d\n", Bin, Decimal);
}

HexSystem()是將十六進制數字轉換成十進制
第43行:因為十六進制有A、B、C、D、E、F因此需要更改ASCII轉換成數字的參數

void HexSystem(){
char Bin[11];
int LastDigit=0;
int Decimal=0, Weight=1;
printf("請輸入十六進制數字(最多10位元,字母請大寫):\n");
scanf("%s", Bin);
while(Bin[LastDigit]!='\0')
LastDigit++;
LastDigit--;
for(int i=LastDigit; i>=0; i--){
if(Bin[i]>=65)
Decimal=Decimal+(Bin[i]-55)*Weight;
else
Decimal=Decimal+(Bin[i]-48)*Weight;
Weight*=16;
}
printf("十六進制數字:%s\n十進制數字 :%d\n", Bin, Decimal);
}

選擇轉換模式

void SelectMode(){
char Mode;
printf("選擇模式:A.二進位; B.八進位; C.十六進位;\n");
Mode=_getche();
printf("\n");
if(Mode=='A')
BinarySystem();
else if(Mode=='B')
OctalSystem();
else if(Mode=='C')
HexSystem();
else{
printf("沒有這種模式!\n");
}
}

主程式,利用do-while的方式重複做。

int main(){
char Choose;
printf("數字系統:轉換成十進位");
do{
SelectMode();
printf("是否要重作?(Y/N)\n");
Choose=_getche();
printf("\n");
}while(Choose=='Y' || Choose=='y');
system("pause");
return 0;
}

因為當中有十六進制,所以採用字元(char)的放式儲存變數。
雖然比使用數學運算式來的耗資源,但是用字元(char)更方便看懂計算過程。

Monday, September 21, 2009

最小公倍數(LCM)

最小公倍數(Least Common Multiple, LCM)是兩個整數共有倍數中最小的一個。

計算最小公倍數時,通常會藉助最大公因數(gcd/hcf)來輔助計算。
公式如下:


計算最小公倍數
請輸入兩個數字:
1st: 55
2nd: 44
最大公因數為:11
最小公倍數為:220
請按任意鍵繼續 . . .

#include <iostream>
using namespace std;
int GCD(int a, int b){
if(a%b){
return GCD(b, a%b);
}
else{
return (b);
}
}
int main(){
int x, y, gcd, lcm;
cout << "計算最小公倍數\n" << "請輸入兩個數字:\n";
cout << "1st: ";
cin >> x;
cout << "2nd: ";
cin >> y;
gcd=GCD(x,y);
cout << "最大公因數為:" << gcd << endl;
lcm=x*y/gcd;
cout << "最小公倍數為:" << lcm << endl;
system("Pause");
return 0;
}

Friday, September 11, 2009

最大公因數(GCD)

最大公因數(Greatest Common Divisor,簡寫為G.C.D.;或Highest Common Factor,簡寫為H.C.F.)
這是很多程式的入門練習題,尤其是使用遞迴呼叫(recursive call)的方式。

如何找出兩個數的最大公因數呢?
最常見的方式是輾轉相除法---輾轉相除法,又名歐幾里得演算法(Euclidean algorithm)乃求兩個正整數之最大公因數的演算法。
這是已知最古老的演算法, 其可追溯至前300年。首次出現於歐幾里得的《幾何原本》(第VII卷,命題i和ii)中,而在中國則可以追溯至東漢出現的《九章算術》。這演算法並不需要把二數作質因數分解。

以下分別以C++實作這兩個方法:

《九章算術》
計算最大公因數
請輸入兩個數字:
1st: 96
2nd: 72
96>72, 96-72=24
24<72, 72-24=48
24<48, 48-24=24
24=24, 最大公因數為:24
請按任意鍵繼續 . . .

#include <iostream>
using namespace std;
int fun(int a, int b)
{
if(a>b)
{
cout << a << ">" << b << ", " << a << "-" << b << "=" << a-b << endl;
return fun(a-b,b);
}
else if(a<b)
{
cout << a << "<" << b << ", " << b << "-" << a << "=" << b-a << endl;
return fun(a,b-a);
}
else
{
cout << a << "=" << b << ", ";
return (a);
}
}
int main(){
int x,y;
cout << "計算最大公因數\n" << "請輸入兩個數字:\n";
cout << "1st: ";
cin >> x;
cout << "2nd: ";
cin >> y;
cout << "最大公因數為:" << fun(x,y) << endl;
system("Pause");
return 0;
}


《幾何原本》
計算最大公因數
請輸入兩個數字:
1st: 96
2nd: 72
96>72, 96%72=24
72%24=0, 最大公因數為:24
請按任意鍵繼續 . . .

#include<iostream>
using namespace std;
int fun(int a, int b){
if(a%b){
cout<<a<<">"<<b<<", "<<a<<"%"<<b<<"="<<a%b<<endl;
return fun(b, a%b);
}
else{
cout<<a<<"%"<<b<<"=0, ";
return (b);
}
}
int main(){
int x,y;
cout<<"計算最大公因數\n"<<"請輸入兩個數字:\n";
cout<<"1st: ";
cin>>x;
cout<<"2nd: ";
cin>>y;
if(x>y)
cout<<"最大公因數為:"<<fun(x,y)<<endl;
else if(x<y)
cout<<"最大公因數為:"<<fun(y,x)<<endl;
else
cout<<"最大公因數為:"<<x<<endl;
system("Pause");
return 0;
}

Sunday, August 02, 2009

調整Vista Auto-Tuning功能

由於買了新的NB搭載新的作業系統Vista,所以讓我開始對他的各項功能感到興趣。其中"改善Vista網路連線",這個詞一直在Google上出現Vista相關的議題。原來是vista新功能"Auto-Tuning"。

什麼是"Auto-Tuning"?
他是能根據網路流量調整接收資料量的緩衝區大小,在Vista中共有Disabled、HighlyRestricted、Restricted、Normal、Experimental等五種設定,後面會在提到他們的意義與指令。
  
如何調整調整Vista Auto-Tuning功能
1.點選"開始",在指令列打上cmd後,將ctrl+shift+enter同時按以取得使用者最高權限。


2.檢查現在的狀況輸入:
netsh interface tcp show global
P.S:我的設定已經是關閉的狀態。

3.關掉Auto-Tuning功能
netsh interface tcp set global autotuninglevel=disabled



附錄:Auto-Tuning功能共有五種參數可供選擇設定---
1. 設為 Disabled    
Disable the autotunning feature in Vista completely、and fit and lock the RWIN receive
window to default value 65,536 bytes.
輸入:
netsh interface tcp set global autotuninglevel=disabled
   
2. 設為HighlyRestricted    
Allow for the receive window to grow beyond the default value、but do so very conservatively.
In this mode、Vista will by default use RWIN of 16,384 bytes with a scale factor of 2.
輸入:
   netsh interface tcp set global autotuninglevel=highlyrestricted
3. 設為Restricted
Allow the receive window to grow beyond its default value、but limit such growth in
some scenarios.
輸入:
   netsh interface tcp set global autotuninglevel=restricted
4.設為 Normal (這是Windows 7,Server 2008,及Vista的預設值)   
Allow for the receive window to grow to accommodate almost all scenarios. The default  
setting in Vista. Specifying this command mean you want to turn back on AutoTuning feature.
輸入:
   netsh interface tcp set global autotuninglevel=normal
5.設為Experimental    
Allow for the receive window to grow to accommodate extreme scenarios. Note The  
experimental value can decrease performance in common scenarios. This value should be
used only for research purposes.
輸入:
   netsh interface tcp set global autotuninglevel=experimental