Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/webadm/public_html/w20120921/lf/class/action/blogaction.class.php on line 306

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/webadm/public_html/w20120921/lf/class/action/blogaction.class.php on line 308

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/webadm/public_html/w20120921/lf/class/action/blogaction.class.php on line 310

Warning: Cannot modify header information - headers already sent by (output started at /home/webadm/public_html/w20120921/lf/class/action/blogaction.class.php:306) in /home/webadm/public_html/w20120921/lf/class/view/view.class.php on line 328

Warning: Cannot modify header information - headers already sent by (output started at /home/webadm/public_html/w20120921/lf/class/action/blogaction.class.php:306) in /home/webadm/public_html/w20120921/lf/class/view/view.class.php on line 175
樹心幽徑 http://oldwww.kmvs.km.edu.tw/lf/index.php?blogId=70 tree 2020-09-21T16:51:36Z 20200917使用LibreOffice scalc並將指定列印範圍的內容列印成pdf檔 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=608&blogId=70 <p><span style="color: #000000;"><span style="color: #000000;">(0)</span></span>下載PDFCreator 繁體中文4.0.3版<a href="https://azure.download.pdfforge.org/pdfcreator/4.0.3/PDFCreator-4_0_3-Setup.exe">安裝版 (31.5MB) 並安裝之。</a></p> <p>(1)<span style="color: #000000;"><span style="color: #000000;">LibreOffice可</span>自 https://zh-tw.libreoffice.org/download/<a href="https://www.libreoffice.org/download/download/">下載LibreOffice 6.3.3安裝程式</a>(LibreOffice_6.3.3_Win_x64.msi, 303MB)並安裝之.</span></p> <p><span style="color: #000000;">(2-1)執行<span style="background-color: #ccffff;">scalc</span>/按CTRL+ALT+DEL/工作管理員/處理程序/按<span style="background-color: #ccffff;">fn+ALT+PRTSCR</span>將現況視窗截圖/貼入在CALC的A2:J36範圍中成第1圖 (按<span style="background-color: #ffff99;">「ALT+TAB<span style="color: #000000;">鍵</span>」</span>可切換AP;按<span style="background-color: #ffff99;">「視窗+方向鍵」</span>可用一半的螢幕來顯示AP)<br /></span></p> <p><span style="color: #000000;"><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/os-1.jpg" alt="alt" width="500" height="442" /><br /></span></p> <p>&nbsp;<span style="color: #000000;">(2-2)工作管理員/效能/CPU/按<span style="color: #000000;"><span style="background-color: #ccffff;">fn+ALT+PRTSCR</span></span>將現況視窗截圖/貼入在CALC的A38:J72範圍中成第2圖</span></p> <p><span style="color: #000000;"><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/os-2.jpg" alt="alt" width="500" height="444" /><br /></span></p> <p>&nbsp;</p> <p><span style="color: #000000;">(2-3)<span style="color: #000000;">工作管理員/效能/GPU/按<span style="color: #000000;"><span style="background-color: #ccffff;">fn+ALT+PRTSCR</span></span>將現況視窗截圖/貼入在CALC的A74:J108範圍中成第3圖</span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/os-3.jpg" alt="alt" width="500" height="448" /><br /></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;">&nbsp;</span></span></p> <p><span style="color: #000000;"><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">(2-4)<span style="color: #000000;">工作管理員/效能/記憶体/按<span style="color: #000000;"><span style="background-color: #ccffff;">fn+ALT+PRTSCR</span></span>將現況視窗截圖/貼入在CALC的A110:J144範圍中成第4圖。</span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/os-4.jpg" alt="alt" width="500" height="450" /><br /></span></span></span></p> <p>&nbsp;</p> <p><span style="color: #000000;"><span style="color: #000000;">(2-5)<span style="color: #000000;">工作管理員/效能/乙太網路/按<span style="color: #000000;"><span style="background-color: #ccffff;">fn+ALT+PRTSCR</span></span>將現況視窗截圖/貼入在CALC的A146:J180範圍中成第5圖。</span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/os-5.jpg" alt="alt" width="500" height="447" /><br /></span></span></span></p> <p>&nbsp;</p> <p><span style="color: #000000;"><span style="color: #000000;">(2-6)<span style="color: #000000;">工作管理員/效能/磁碟0(C:)/按<span style="color: #000000;"><span style="background-color: #ccffff;">fn+ALT+PRTSCR</span></span>將現況視窗截圖/貼入在CALC的A182:J216範圍中成第6圖。</span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/os-6.jpg" alt="alt" width="500" height="444" /><br /></span></span></span></p> <p>(2-7)於「工作表1」處按右鍵/選「重新命名工作表」/將「工作表1」改名為「工作表1-工作管理員」</p> <p>&nbsp;</p> <p>(3)製作三種CPU工作排程圖:</p> <p>在LIbreOffice的CALC新增另一工作表,並改名為「工作表2-CPU工作排程」 並在其中輸入如下圖的資料</p> <p><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200305LibreOfficeCalc-2.png" alt="alt" width="500" height="228" /></p> <p>&nbsp;</p> <p>(3-1)FCFS先到先執行:</p> <p><span style="background-color: #ffff00;">A(19)B(3)C(8) 平均等待時間=(0+19+22)/3=13.67</span></p> <p>(3-1a)按CTRL+A(全選)/拖曳任一欄格線可改變所有欄的寬度</p> <p>(3-1b)在A3輸入A01/在右下角往右拖曳直到A19出現。</p> <p>(3-1c)在T3輸入B01/在右下角往右拖曳直到B03出現。</p> <p>(3-1d)在W3輸入C01/在右下角往右拖曳直到C08出現。</p> <p>(3-1e)在A4輸入0/在右下角往右拖曳直到30出現。</p> <p>(3-1f)點選第2列頭並拖曳到第5列來選取連續四列並按CTRL+C複製/點選A6並按CTRL+V貼入剛複製的4列</p> <p>並調整內容以表示「<span style="background-color: #ffff00;">C(8)B(3)A(19) 平均等待時間=(0+8+11)/3=6.33</span>」。</p> <p>&nbsp;</p> <p>(3-2)SJF最短工作優先</p> <p>B(3)C(8)A(19) 平均等待時間=(0+3+11)/3=4.67</p> <p>&nbsp;</p> <p>(3-3)有優先權者優先</p> <p>C(8)A(19)B(3) 平均等待時間=(0+8+27)/3=11.67</p> <p>&nbsp;</p> <p>(3-4a)選A1:AE17/格式/列印範圍/定義</p> <p>(3-4b)檔案/預覽列印/設定頁面格式/頁面:選<span style="background-color: #ffff00;">橫向</span>/工作表:顯示比例/縮放模式:選列印符合1頁寬及1頁高。</p> <p>(3-5)CALC/檔案/列印/印表機挑「PDFCreator」/列印成PDF檔在桌面,檔名給20200317-2.pdf</p> <p>詳如範例檔:20200317-2.pdf<a href="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200317-2.pdf"> 下載</a> (69 KB)</p> <p>&nbsp;</p> <p>(3-6)在CALC點選「工作表1-工作管理員」/選取範圍A1:J218/格式功能表/列印範圍/定義,</p> <p>並參考(3-4b)預覽列印/設定頁面格式/頁面:選<span style="background-color: #ffff00;">縱向</span>/工作表:顯示比例/縮放模式:選列印符合1頁寬及<span style="background-color: #ffff00;">3頁高</span>。&nbsp;</p> <p>&nbsp;</p> <p>(3-7)同3-5操作將3-6的內容列印成桌面的20200317-1.pdf&nbsp;</p> <p>詳如範例檔:20200317-1.pdf<a href="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200317-1.pdf"> 下載</a> (410 KB)</p> <p>&nbsp;</p> <p><span style="background-color: #ccffff;">(3-8)請把(3-7)所產生的PDF檔改名為「你名你號.pdf」並上傳至<a id="C-1226" class="tab-ctl-x" title="學生學習歷程系統(另開啟新視窗)" tabindex="0" href="http://stu.kmvs.km.edu.tw/Ncnu_EPortfolio" target="_blank">「金門農工學生學習歷程系統</a>」成為你的資訊科技學習檔案。</span></p> <p>&nbsp;</p> <p>&nbsp;</p> <p>(4)TCPIP畫面截圖:</p> <p>(4-0) 在LIbreOffice的CALC新增另一工作表,並改名為「工作表3-TCPIP」 並在其中貼入如下操作畫面的截圖</p> <p><span style="color: #000000;">(4-1)執行cmd/輸入ipconfig/按<span style="color: #000000;"><span style="background-color: #ccffff;">fn+ALT+PRTSCR</span></span>將現況視窗截圖/貼入CALC「工作表3-TCPIP」的<span style="background-color: #ffff00;">A2:J36</span>範圍中成第d1圖</span></p> <p><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/ipconfig.jpg" alt="alt" width="500" height="340" /></p> <p><span style="color: #000000;">(4-2)WIN10/控制台/網路連線/內容/TCPIPv4/內容/按<span style="color: #000000;"><span style="background-color: #ccffff;">fn+ALT+PRTSCR</span></span>將現況視窗截圖/貼入CALC「工作表3-TCPIP」的<span style="color: #000000; background-color: #ffff00;">A38:J72</span>範圍中成第d2圖</span></p> <p><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/win10-tcpip.jpg" alt="alt" width="412" height="431" /></p> <p>&nbsp;</p> <p><span style="color: #000000;">(4-3)執行cmd/輸入nslookup/<span style="color: #000000;">輸入</span>www.ntu.edu.tw/<span style="color: #000000;">輸入</span>www.kmvs.km.edu.tw/<span style="color: #000000;">輸入</span>quit/按<span style="color: #000000;"><span style="background-color: #ccffff;">fn+ALT+PRTSCR</span></span>將現況視窗截圖/貼入CALC「工作表3-TCPIP」的<span style="background-color: #ffff00;">A74:J108</span>範圍中成第d3圖</span></p> <p><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/nslookup.jpg" alt="alt" width="500" height="374" /></p> <p>&nbsp;</p> <p>(4-4a)選取工作表3的A1:J108/格式功能表/列印範圍/定義</p> <p>(4-4b)檔案/預覽列印/設定頁面格式/頁面:選<span style="background-color: #ffff00;">橫向</span>/工作表:顯示比例/縮放模式:選列印符合1頁寬及2頁高。</p> <p>(4-4c)檔案/列印/印表機挑「PDFCreator」/列印成PDF檔在桌面,檔名給20200317-3.pdf<span style="color: #000000;"><span style="color: #000000;">,</span></span>詳如如下範例檔:</p> <p>20200317-3.pdf<a href="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200317-3.pdf">下載</a> (151 KB)</p> <p>&nbsp;</p> <p><br /><span style="color: #000000;"><span style="color: #000000;">(5)將在scalc試算表的編修存在桌面為20200317你名你號.ods,</span></span>詳如如下範例檔:</p> <p>20200317calc.ods<a href="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200317calc.ods"> 下載</a> (468 KB)</p> <p>&nbsp;</p> 一般 2020-09-17T14:44:07Z tree 20200831用LibreOffice的writer製作組裝一台中階個人電腦的零件選購清單 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=607&blogId=70 <p><span style="color: #000000;">REF0:歐飛先生部落格-如何選購組裝一台高CP值的電腦 <a href="https://ofeyhong.pixnet.net/blog/post/222532089">https://ofeyhong.pixnet.net/blog/post/222532089</a></span></p> <p><span style="font-size: small; color: #000000;">(一)中央處理器(CPU):<span style="font-size: small;"> </span><strong>買性能好的可以玩高速的電動。</strong></span></p> <p><span style="font-size: small; color: #000000;">INTEL i7-9700K【8核/8緒】3.6GHz(&uarr;4.9GHz)/UHD630<span style="font-size: small; color: #000000;"><span style="font-size: small; color: #000000;">內建顯示晶片</span></span>/<strong>12M快取/14nm製程/65W/約1.2萬元 //LGA 1151插槽 (可超頻K版CPU要搭配可超頻的Z系列主機板才行)<br /></strong></span></p> <p><span style="color: #000000; font-family: arial black, avant garde;"><strong><span style="color: #217e99;">INtel: 2020年的第十代i7-10700【8核/16緒】</span></strong></span></p> <p><span style="color: #000000; font-family: arial black, avant garde;"><span style="color: #217e99;">AMD:</span> <strong><span style="color: #217e99;"><span style="font-size: 18px;"><span style="color: #217e99;"><strong>R7-4750G </strong>【12核/16緒】PRO 3.6GHz(&uarr;4.4GHz)/12MB/Vega 8/含風扇</span></span></span></strong></span></p> <p>&nbsp;</p> <p><span style="color: #000000;">Ref 1 :CPU選購與推薦:<a class="external free" rel="nofollow" href="https://ofeyhong.pixnet.net/blog/post/59877783">https://ofeyhong.pixnet.net/blog/post/59877783</a></span></p> <p>&nbsp;</p> <p><span style="color: #000000;">(二)RAM主記憶體(Main Memory):2020年6月一支8GB回到1千元左右</span></p> <p><span style="color: #000000;">2020年新款的主機板來說,大部份都有到最高64G,舊主機板可能無法支援16GB</span></p> <p><span style="color: #000000;">WIN10家用版 64位元最高支援到128G 記憶體,WIN10 專業版 64位元支援到2TB。</span></p> <p><span style="color: #000000;"><span style="color: #e17704;"><strong>&nbsp;</strong></span><strong>記憶體頻寬:DDR2、DDR3、DDR4</strong> <strong>不同的頻寬是不相容的,也無法混插</strong>;</span></p> <p><span style="color: #000000;">DDR4-2666&nbsp; 8GB*2條=16GB&nbsp; 可跑雙通道,一條8GB約1100元,二條計2200元。</span></p> <p><span style="color: #000000;"><strong>理論上DDR4時脈可以到4266Mhz,容量128GB</strong></span></p> <p><a href="https://www.isunfar.com.tw/product/?prodseq=252T06#/bcNo=A32&amp;ept=8L"><span style="color: #000000;">Transcend 創見 <span id="main_prod_cname">DDR4 2666 8G JETRAM PC用</span></span></a></p> <p><span style="color: #000000;">Ref 2 :RAM選購與推薦:<a href="https://ofeyhong.pixnet.net/blog/post/59851482">https://ofeyhong.pixnet.net/blog/post/59851482</a></span></p> <p>&nbsp;</p> <p><span style="color: #000000;">(三)主機板(MotherBoard):要穩定且具擴充性,國內有四大廠:<strong>華碩、技嘉、微星、華擎。</strong></span></p> <p><span style="color: #000000;"><a href="https://news.xfastest.com/review/47706/gigabyte-h370-aorus-gaming-3-wifi/"><strong>技嘉 H370</strong> AORUS GAMING 3 WIFI </a><span style="font-size: 16px;">(ATX/1D1H/I網/ac+BT5/註五年) 約5000元。</span></span></p> <p><span style="color: #000000;"><span style="font-size: 16px;">採<span style="font-size: 16px;">H370</span>晶片組、有WIFI<span style="font-size: 16px;">&nbsp;</span>、ATX機殼、<span style="font-size: 16px;">、1個DVI視訊接頭、1個HDMI<span style="font-size: 16px;">視訊接頭</span></span>、內建Intel網路晶片、支援<span style="font-size: 16px;"><span style="font-size: 16px;">802.11ac無線及</span></span>藍牙5、註冊後可享五年保固。</span></span></p> <p><span style="color: #000000;"><span style="font-size: 16px;">USB插孔六個:分別是USB-3.1、USB-TYPE-C各一<span style="font-size: 16px;">(粉紅)</span>、<span style="font-size: 16px;">&nbsp;</span>USB-2.0二個<span style="font-size: 16px;">(<span style="font-size: 16px;">黑)</span></span>、<span style="font-size: 16px;">USB-3.0二個<span style="font-size: 16px;">(藍)</span>。</span></span></span></p> <p><span style="color: #000000;"><span style="font-size: 16px;"><span style="font-size: 16px;">2020年intel是第十代(1200插槽,第十代搭配<a href="http://ark.intel.com/content/www/tw/zh/ark/products/series/201843/intel-400-series-chipsets.html" target="_blank">400系列晶片組</a>主機板,例如Z<span style="color: #ff0000;"><strong>4</strong></span>90、H<span style="color: #ff0000;"><strong>4</strong></span>70、B<span style="color: #ff0000;"><strong>4</strong></span>60,<strong>低到高B-H-Z-X</strong>),AMD 是Ryzen第三代及第四代(AM4插槽)</span></span></span></p> <p><span style="color: #000000;">Ref 3 :主機板選購與推薦:<a href="https://ofeyhong.pixnet.net/blog/post/59878626">https://ofeyhong.pixnet.net/blog/post/59878626</a></span></p> <p>&nbsp;</p> <p><span style="color: #000000;">(四a)固態硬碟(SSD,Solid State Disk)<span style="font-size: small;">&nbsp;</span>:安裝作業系統及應用程式。</span></p> <p><span style="color: #000000; font-size: small;"><a href="https://24h.pchome.com.tw/prod/DRAH7G-A9009CPQM">美光 MX500 500GB/2.5" 7mm/讀:560M/寫:510M/TLC</a>, 約2500元。<br /></span></p> <p><span style="color: #000000;">Ref 4a :SSD選購與推薦:<a href="https://ofeyhong.pixnet.net/blog/post/193264786">https://ofeyhong.pixnet.net/blog/post/193264786</a></span></p> <p>&nbsp;</p> <p><span style="color: #000000;">(四b)硬碟(HARD DISK):用來放資料,民國76年一台20MB的硬碟要價1萬元。</span></p> <p><span style="color: #000000;">Seagate 1TB<strong>【新梭魚】 </strong>64M/7200轉/三年保&nbsp; 約2000元。</span></p> <p><span style="color: #000000;"><span style="color: #000000;">1TB=</span>1024GB&nbsp; <span style="color: #000000;"><span style="color: #000000;">, 1GB=</span>1024MB,&nbsp; </span></span></p> <p><span style="color: #000000;"><span style="color: #000000;">2TB以上的硬碟不能採用MBR(Master Boot Record)分割,要改用GPT分割(</span></span>GUID Partition Table<span style="color: #000000;"><span style="color: #000000;">)。<br /></span></span></p> <p><span style="color: #000000;">Ref 4b :硬碟選購與推薦:<a href="https://ofeyhong.pixnet.net/blog/post/59288574">https://ofeyhong.pixnet.net/blog/post/59288574</a></span></p> <p>&nbsp;</p> <p><span style="color: #000000;">(四c)DVD燒錄機(DVD-RW):光碟機有CD,DVD及BD三大類型。</span></p> <p><span style="color: #000000;">華碩 藍光COMBO機 12X 藍光讀/16X DVD燒 (約 2千元)</span></p> <p><span style="color: #000000;">Ref 4c :<span style="color: #000000;">DVD燒錄機</span>選購與推薦:<a href="https://ofeyhong.pixnet.net/blog/post/60337962">https://ofeyhong.pixnet.net/blog/post/60337962</a></span></p> <p><span style="color: #000000;">&nbsp;</span></p> <p><span style="color: #000000;">(五)獨立顯示卡:<strong>GTX</strong><span style="color: #217e99;"><strong>16</strong></span><strong><span style="color: #ff00ff;">6</span></strong>0Ti GAMING OC 6G <span style="font-size: 16px;"> (1860MHz/28cm) 約5000元。<br /></span></span></p> <p>也可不買,使用「主機板內建的顯示晶片」。中階顯卡最少搭配4GB記憶體,高階顯卡通常是6~11GB(很耗電,1萬元以上,玩VR要90FPS以上)</p> <p><span style="color: #000000;"><span style="color: #000000;">Ref 5 :<span style="color: #000000;">顯示卡</span>選購與推薦:</span><a href="https://ofeyhong.pixnet.net/blog/post/58511370">https://ofeyhong.pixnet.net/blog/post/58511370</a></span></p> <p><span style="color: #000000;"><br /></span></p> <p><span style="color: #000000;"><span style="color: #000000;">(六)電源供應器(PowerSupply):</span></span></p> <table width="100%" cellspacing="1" cellpadding="0" border="0" bgcolor="#F1F1F1" align="center"> <tbody> <tr> <td align="center">全漢</td> <td><a title="全漢 黑騎士 550W" href="http://www.arclink.com.tw/productDetail.do?subId=19&amp;pId=8016&amp;pg=topic">黑騎士 550W</a>&nbsp;<span style="color: #cccccc;">/</span>&nbsp;80+銀牌/ 全日系電容</td> <td align="right">2200元</td> <td><br /></td> </tr> </tbody> </table> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">Ref 6 <span style="color: #000000;"><span style="color: #000000;">電源供應器</span></span>選購與推薦:</span></span><a href="https://ofeyhong.pixnet.net/blog/post/57302139">https://ofeyhong.pixnet.net/blog/post/57302139</a></span></span></p> <p><span style="color: #000000; font-family: arial black, avant garde; font-size: small; background-color: #ffffff;"><span style="color: #000000;"><span style="color: #000000;">(七)機殼(Case):</span></span> <strong>&nbsp;</strong></span></p> <p><span style="color: #000000; font-family: arial black, avant garde; font-size: small; background-color: #ffffff;"><strong>酷碼<a href="https://24h.pchome.com.tw/prod/DRAE0O-A77722399">&nbsp;N400 &nbsp;(ATX/5.25槽*2/內建風扇前1後1/顯卡320mm/塔散164mm)</a> 約1500元。</strong></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">Ref 7 <span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">機殼</span></span></span></span></span>選購與推薦:<a href="https://ofeyhong.pixnet.net/blog/post/57221160">https://ofeyhong.pixnet.net/blog/post/57221160</a></span></span></span></span></span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">(八)液晶顯示器(LCD):<a href="https://24h.pchome.com.tw/prod/DSABE8-A900AD4K0" target="_blank">ASUS VA24EHE 24吋</a>&nbsp;<span style="font-size: 16px;">(有附HDMI線) 約4000元</span></span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">Ref 8 <span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">液晶顯示器</span></span></span></span></span></span></span></span>選購與推薦:<a href="https://ofeyhong.pixnet.net/blog/post/60350154">https://ofeyhong.pixnet.net/blog/post/60350154</a></span></span></span></span></span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><br /></span></span></span></span></span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;">(九a)鍵盤(keyboard)<span style="color: #000000;"><span style="color: #000000;">與滑鼠(Mouse):</span></span>:Pchome:<a href="https://24h.pchome.com.tw/prod/DSAR0M-A62078948" target="_blank">羅技 MK200 有線鍵鼠組</a>&nbsp;約600元</span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">(九b)</span></span>喇叭(Speaker):Pchome:<a href="https://mall.pchome.com.tw/prod/QABF0X-A9008VCDH" target="_blank">羅技Z150 多媒體音箱</a> 約700元</span></span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">Ref 9 <span style="color: #000000;"><span style="color: #000000;">鍵盤<span style="color: #000000;"><span style="color: #000000;">滑鼠<span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">喇叭</span></span></span></span></span></span></span></span>選購與推薦:</span></span></span></span></span></span></span><a href="https://ofeyhong.pixnet.net/blog/post/62410674">https://ofeyhong.pixnet.net/blog/post/62410674</a></span></span></span></span></p> <p>&nbsp;</p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">(<span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">十</span></span></span></span>)作業系統(OS)、辦公室軟體、防毒軟體:</span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">Ref 10 <span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">作業系統</span></span></span>選購與推薦:<a href="https://ofeyhong.pixnet.net/blog/post/206658040">https://ofeyhong.pixnet.net/blog/post/206658040</a></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">(a)作業系統</span></span></span>:MS-Win10家用彩盒版約5000元<span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">(也可下載安裝免費的自由軟體 ubuntu Linux)</span></span></span></span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">(b)辦公室軟體</span></span></span>: </span></span></span></span></span></span>MS-<span style="color: #217e99;"><strong>Office 2019&nbsp;家用版 </strong>&nbsp;約4500元</span>(也可<span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">下載安</span></span></span></span></span></span>裝免費的自由軟體 <a href="https://ofeyhong.pixnet.net/blog/post/223897812" target="_blank">LibreOffice</a> )</span></span></span></p> <p><span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">(c)<span style="color: #000000;"><span style="color: #000000;"><span style="color: #000000;">防毒軟體: </span></span></span>MS-Windows Defender(win10內建) <br /></span></span></span></p> <p>&nbsp;</p> <p>(十一)其他:光華商場報價網站&nbsp; http://www.arclink.com.tw/ &nbsp;<span style="color: #000000;"><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=379&amp;blogId=70"> 20180106PC-DIY清單</a></span></p> <p><span style="color: #000000;"><br /></span></p> <p><span style="color: #000000;">(十二)用LibreOffice的writer製作選購清單如下截圖,<span style="font-size: small;">並存檔為「20200915餐一你號你名.odt」(</span></span>pcdiy空表.odt<a href="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/pcdiy%E7%A9%BA%E8%A1%A8.odt">下載</a> )</p> <p><span style="color: #000000;"><span style="font-size: small;">並再&nbsp;匯出為PDF檔(檔名為「<span style="color: #000000;"><span style="font-size: small;">20200915<span style="color: #000000;"><span style="font-size: small;">餐一</span></span></span></span>你號你名.pdf」,自動取用odt檔的主檔名)</span>:</span></p> <p><span style="color: #000000;"><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200225odf-pcdiy.jpg" alt="alt" width="800" height="601" /><br /></span></p> <p><span style="color: #000000;"><span style="color: #000000;">註:LibreOffice可</span>自 https://zh-tw.libreoffice.org/download/<a href="https://www.libreoffice.org/download/download/">下載LibreOffice 6.3.3安裝程式</a>(LibreOffice_6.3.3_Win_x64.msi, 303MB)並安裝之.</span></p> <p><span style="color: #000000;">(十三) 請把上述所產生的PDF檔上傳至<a id="C-1226" class="tab-ctl-x" title="學生學習歷程系統(另開啟新視窗)" tabindex="0" href="http://stu.kmvs.km.edu.tw/Ncnu_EPortfolio" target="_blank"><span>「金門農工學生學習歷程系統</span></a>」成為你的</span><span style="color: #000000;">資訊科技學習檔案。</span></p> 一般 2020-08-31T13:35:18Z tree 20200827將android手機中的照片傳到Ubuntu 電腦 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=606&blogId=70 <p>20200827將android手機中的照片傳到電腦</p> <p>(0)參考1 : <a href="https://www.linuxquestions.org/questions/linux-newbie-8/connecting-google-pixel-phone-to-ubuntu-computer-4175592209/">https://www.linuxquestions.org/questions/linux-newbie-8/connecting-google-pixel-phone-to-ubuntu-computer-4175592209/</a></p> <p>(1)手機端要開啟開發者模式(developer mode):</p> <p>Apps&gt;Settings&gt;Developer</p> <p>(2)手機端要設定USB:</p> <p>Apps&gt;Settings&gt;Developer&gt;USB settings&gt;MTP</p> <p>(3)使用<strong>Ubuntu computer的</strong> shotwell應用程式匯入選取的照片。</p> 一般 2020-08-27T09:32:01Z tree 20200701用JavaScript設計二分搜尋法 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=605&blogId=70 <p>(0-1)二分搜尋法所要搜尋的資料數列,要先排序才可行。</p> <p>&nbsp;</p> <p>(0-2)要用二分搜尋法在給定的資料數列搜尋數字K,過程如下:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; 「 將K和「數列的中間數」比較, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果二數相等,則在數列中找到有K,搜尋結束。<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果K比中間數大,則往「大的那一方」找,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果K比中間數小,則往「小的那一方」找,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果待尋「那一方」不存在則搜尋結束。」<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 不管往「大的那一方」或「小的那一方」搜尋皆採同上處理方式。</p> <p>&nbsp;</p> <p>(1-1)<span style="background-color: #ccffcc;">在notepad輸入如下JS程式碼並存檔在桌面為bs01.htm</span></p> <p><span style="background-color: #ccffcc;">&lt;script&gt;</span><br /><span style="background-color: #ccffcc;">&nbsp;</span></p> <p><span style="background-color: #ccffcc;">var a = [1, 13, 5, 26, 7 , 18 , 9];</span></p> <p><span style="background-color: #ccffcc;"><br />function bsearch(k){<br />&nbsp;&nbsp;&nbsp; document.write("&lt;hr&gt;數字k="+k+"的搜尋結果如下:");<br />&nbsp;&nbsp;&nbsp; var L=0;<br />&nbsp;&nbsp;&nbsp; var R=a.length-1;<br />&nbsp;&nbsp;&nbsp; var M=(L+R)/2;<br />&nbsp;&nbsp;&nbsp; while (L&lt;=R){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.write("&lt;br&gt; L="+L+" a[L]="+a[L]+", R="+R+" a[R]="+a[R]+", M="+M+" a[M]="+a[M]+"");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (a[M]==k) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.write("&lt;br&gt; 找到一筆匹配在 M="+ M + " a[M]="+a[M]);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (k &gt;a[M]) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; L=M+1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.write("&lt;br&gt; k="+k+" &gt; a[M]="+a[M]+" 往大的那一半找 =&gt; L="+L+" R=" +R + "&lt;br&gt;");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; R=M-1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.write("&lt;br&gt; k="+k+" &lt; a[M]="+a[M]+" 往小的那一半找 =&gt;&nbsp; L="+L+" R=" +R + "&lt;br&gt;");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M=(L+R)/2;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (L&gt;R) document.write(" &lt;br&gt; 因"+L+"=L&nbsp; &gt;&nbsp; R="+R+" =&gt; [L,R]的數字區間不存在,故找不到k="+k);<br />}</span></p> <p><span style="background-color: #ccffcc;">a.sort(function(a, b){return a - b;});<br />document.write("二分搜尋法&lt;br&gt;待搜尋陣列a[]="+a);<br /><br />var k= parseInt(prompt("請輸入k=","7"));<br />document.write("&lt;HR&gt;你輸入的k=" + k + "&lt;br&gt;");<br /><br />bsearch(k);<br /><br /><br />&lt;/script&gt;</span></p> <p><span style="background-color: #ccffcc;"><br /></span></p> <p><span style="background-color: #ffffff;">(2) 用firefox開啟bs01.htm並輸入8,瀏覽結果如下:</span></p> <p><span style="background-color: #ffff99;">二分搜尋法<br />待搜尋陣列a[]=1,5,7,9,13,18,26 </span></p> <hr /> <p><span style="background-color: #ffff99;"> 你輸入的k=8</span></p> <hr /> <p><span style="background-color: #ffff99;"> 數字k=8的搜尋結果如下:</span><br /><span style="background-color: #ffff99;"> L=0 a[L]=1, R=6 a[R]=26, M=3 a[M]=9</span><br /><span style="background-color: #ffff99;"> k=8 &lt; a[M]=9 往小的那一半找 =&gt; L=0 R=2</span><br /><br /><span style="background-color: #ffff99;"> L=0 a[L]=1, R=2 a[R]=7, M=1 a[M]=5</span><br /><span style="background-color: #ffff99;"> k=8 &gt; a[M]=5 往大的那一半找 =&gt; L=2 R=2</span><br /><br /><span style="background-color: #ffff99;"> L=2 a[L]=7, R=2 a[R]=7, M=2 a[M]=7</span><br /><span style="background-color: #ffff99;"> k=8 &gt; a[M]=7 往大的那一半找 =&gt; L=3 R=2</span><br /> <br /><span style="background-color: #ffff99;"> 因3=L &gt; R=2 =&gt; [L,R]的數字區間不存在,故找不到k=8</span></p> <p>&nbsp;</p> <p>(3)<span style="background-color: #ffffff;">按f5鍵重新整理firefox中的bs01.htm並輸入7,瀏覽結果如下:</span></p> <p><span style="background-color: #ffff99;">二分搜尋法</span><br /><span style="background-color: #ffff99;">待搜尋陣列a[]=1,5,7,9,13,18,26 </span></p> <hr /> <p><span style="background-color: #ffff99;"> 你輸入的k=7</span></p> <hr /> <p><span style="background-color: #ffff99;"> 數字k=7的搜尋結果如下:</span><br /><span style="background-color: #ffff99;"> L=0 a[L]=1, R=6 a[R]=26, M=3 a[M]=9</span><br /><span style="background-color: #ffff99;"> k=7 &lt; a[M]=9 往小的那一半找 =&gt; L=0 R=2</span><br /><br /><span style="background-color: #ffff99;"> L=0 a[L]=1, R=2 a[R]=7, M=1 a[M]=5</span><br /><span style="background-color: #ffff99;"> k=7 &gt; a[M]=5 往大的那一半找 =&gt; L=2 R=2</span><br /><br /><span style="background-color: #ffff99;"> L=2 a[L]=7, R=2 a[R]=7, M=2 a[M]=7</span><br /><span style="background-color: #ffff99;"> 找到一筆匹配在 M=2 a[M]=7</span></p> <p>&nbsp;</p> <p>(3)</p> <p>&lt;script&gt;<br />var a = [1, 5, 7 ,9,13, 18 , 26];<br /><br />function bs(k){<br />&nbsp;&nbsp;&nbsp; document.write("&lt;hr&gt;搜尋"+k+"如下:");<br />&nbsp;&nbsp;&nbsp; var L=0;<br />&nbsp;&nbsp;&nbsp; var R=a.length-1;<br />&nbsp;&nbsp;&nbsp; var M=(L+R)/2;<br />&nbsp;&nbsp;&nbsp; while (L&lt;=R){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (a[M]==k) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.write("找到"+k+"在a["+ M+"]處" );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (k &gt;a[M]) L=M+1;&nbsp;&nbsp; else&nbsp;&nbsp; R=M-1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M=(L+R)/2;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (L&gt;R) document.write(" &lt;br&gt; 找不到 "+k);<br />}<br /><br />document.write("&lt;hr&gt;a[]="+a+ ":");<br />var k= parseInt(prompt("k=","7"));<br />bs(k);<br />&lt;/script&gt;</p> <p>&nbsp;</p> <p>(4)</p> <p>a[]=1,5,7,9,13,18,26:</p> <hr /> <p>搜尋7如下:找到7在a[2]處</p> <p>&nbsp;</p> <p>REF-1:2<a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=559&amp;blogId=70">0200102用JavaScript設計二分搜尋法bs01.htm</a></p> 一般 2020-06-30T21:55:28Z tree 20200619用JavaScript來編寫氣泡排序法及選擇排序法程式 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=602&blogId=70 <h3>(1)IT重點:20200623ITLast.odt<a href="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200623ITLast.odt"> 下載</a> (16 KB) | created 23 六月, 2020</h3> <div></div> <p>(1-1)<span style="background-color: #ccffff;"><span style="background-color: #ccffcc;">在notepad輸入如下JS程式碼並存檔</span></span>為d:\bsort.htm</p> <p><span style="background-color: #ffff99;">&lt;script&gt;</span><br /><span style="background-color: #ffff99;">var a = [9, 5, 8, 7, 6 , 4 ];</span><br /><span style="background-color: #ffff99;">function bsort(){</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; var size=a.length;</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; document.write("待排陣列計有"+size+"個元素&lt;br&gt;");</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; for (i=0;i&lt;= size-2;i++){</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (j=0;j&lt;=size-2-i;j++){</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (a[j]&gt;a[j+1]) {</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.write("交換前 at j=" + j + "(" + a[j] + "," + a[j+1] + ")");</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t=a[j];&nbsp; a[j]=a[j+1];&nbsp; a[j+1]=t;</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; document.write("--&gt;交換後 a[]="+a +"&lt;br&gt;");</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; document.write("無交換 at j=" + j + "(" + a[j] + "," + a[j+1] + ")&lt;br&gt;");</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; document.write("&lt;br&gt;第"+ i +"回合結果: a[]="+a +"&lt;HR color=green&gt;");</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; }</span><br /><span style="background-color: #ffff99;">}</span><br /><br /><span style="background-color: #ffff99;">document.write("氣泡排序法排序前 a[]="+a+"&lt;hr color=red&gt;");</span><br /><span style="background-color: #ffff99;">bsort();</span><br /><span style="background-color: #ffff99;">&lt;/script&gt;</span></p> <p>&nbsp;</p> <p><span style="background-color: #ccffff;"><br /></span></p> <p>&nbsp;</p> <p>(1-2)用firefox開啟d:\bsort.htm,瀏覽結果如下:</p> <p><span style="background-color: #ffff99;">氣泡排序法排序前 a[]=9,5,8,7,6,4 </span></p> <hr /> <p><span style="background-color: #ffff99;"> 待排陣列計有6個元素</span><br /><span style="background-color: #ffff99;">交換前 at j=0(9,5)--&gt;交換後 a[]=5,9,8,7,6,4</span><br /><span style="background-color: #ffff99;">交換前 at j=1(9,8)--&gt;交換後 a[]=5,8,9,7,6,4</span><br /><span style="background-color: #ffff99;">交換前 at j=2(9,7)--&gt;交換後 a[]=5,8,7,9,6,4</span><br /><span style="background-color: #ffff99;">交換前 at j=3(9,6)--&gt;交換後 a[]=5,8,7,6,9,4</span><br /><span style="background-color: #ffff99;">交換前 at j=4(9,4)--&gt;交換後 a[]=5,8,7,6,4,9</span><br /><br /><span style="background-color: #ffff99;">第0回合結果: a[]=5,8,7,6,4,9 </span></p> <hr /> <p><span style="background-color: #ffff99;"> 無交換 at j=0(5,8)</span><br /><span style="background-color: #ffff99;">交換前 at j=1(8,7)--&gt;交換後 a[]=5,7,8,6,4,9</span><br /><span style="background-color: #ffff99;">交換前 at j=2(8,6)--&gt;交換後 a[]=5,7,6,8,4,9</span><br /><span style="background-color: #ffff99;">交換前 at j=3(8,4)--&gt;交換後 a[]=5,7,6,4,8,9</span><br /><br /><span style="background-color: #ffff99;">第1回合結果: a[]=5,7,6,4,8,9 </span></p> <hr /> <p><span style="background-color: #ffff99;"> 無交換 at j=0(5,7)</span><br /><span style="background-color: #ffff99;">交換前 at j=1(7,6)--&gt;交換後 a[]=5,6,7,4,8,9</span><br /><span style="background-color: #ffff99;">交換前 at j=2(7,4)--&gt;交換後 a[]=5,6,4,7,8,9</span><br /><br /><span style="background-color: #ffff99;">第2回合結果: a[]=5,6,4,7,8,9 </span></p> <hr /> <p><span style="background-color: #ffff99;"> 無交換 at j=0(5,6)</span><br /><span style="background-color: #ffff99;">交換前 at j=1(6,4)--&gt;交換後 a[]=5,4,6,7,8,9</span><br /><br /><span style="background-color: #ffff99;">第3回合結果: a[]=5,4,6,7,8,9 </span></p> <hr /> <p><span style="background-color: #ffff99;"> 交換前 at j=0(5,4)--&gt;交換後 a[]=4,5,6,7,8,9</span><br /><br /><span style="background-color: #ffff99;">第4回合結果: a[]=4,5,6,7,8,9 </span></p> <hr /> <p>&nbsp;</p> <p><span style="background-color: #ffffff;">(2-1)在notepad輸入如下JS程式碼並存檔在桌面為ssort.htm</span></p> <p><span style="background-color: #ffff99;">&lt;script&gt;</span><br /><span style="background-color: #ffff99;">var b = [9, 5, 8, 1, 3 ];</span><br /><br /><span style="background-color: #ffff99;">function ssort(){</span><br /><span style="background-color: #ffff99;">&nbsp; var size=b.length;</span><br /><span style="background-color: #ffff99;">&nbsp; document.write("待排陣列計有"+size+"個元素&lt;br&gt;");</span><br /><br /><span style="background-color: #ffff99;">&nbsp; for (i=0;i&lt;size-1;i++){</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var mini=i;</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (j=i+1;j&lt;size;j++){</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (b[j]&lt;b[mini]) mini=j;</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.write("&lt;br&gt;i=" + i+ "交換前b[" + i + "]=" + b[i]+ ", b[" + mini+"]" + "=" + b[mini] + " mini=" +mini);</span><br /><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t=b[mini];</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b[mini]=b[i];</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b[i]=t;</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.write("&lt;br&gt;第"+i +"回合結果:b[]="+b +"&lt;HR color=red&gt;");</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br /><span style="background-color: #ffff99;">}</span><br /><br /><span style="background-color: #ffff99;">document.write("選擇排序法排序前 b[]="+b +"&lt;HR color=green&gt;");</span><br /><span style="background-color: #ffff99;">ssort();</span><br /><span style="background-color: #ffff99;">document.write("&lt;br&gt;排序後 b[]="+b);</span><br /><span style="background-color: #ffff99;">&lt;/script&gt;</span></p> <p>&nbsp;</p> <p><span style="background-color: #ffffff;">(2-2)用firefox開啟d:\ssort.htm,瀏覽結果如下:</span></p> <p><span style="background-color: #ffff99;">選擇排序法排序前 b[]=9,5,8,1,3 </span></p> <hr /> <p><span style="background-color: #ffff99;"> 待排陣列計有5個元素</span><br /><br /><span style="background-color: #ffff99;">i=0交換前b[0]=9, b[3]=1 mini=3</span><br /><span style="background-color: #ffff99;">第0回合結果:b[]=1,5,8,9,3 </span></p> <hr /> <p><br /><span style="background-color: #ffff99;">i=1交換前b[1]=5, b[4]=3 mini=4</span><br /><span style="background-color: #ffff99;">第1回合結果:b[]=1,3,8,9,5 </span></p> <hr /> <p><br /><span style="background-color: #ffff99;">i=2交換前b[2]=8, b[4]=5 mini=4</span><br /><span style="background-color: #ffff99;">第2回合結果:b[]=1,3,5,9,8 </span></p> <hr /> <p><br /><span style="background-color: #ffff99;">i=3交換前b[3]=9, b[4]=8 mini=4</span><br /><span style="background-color: #ffff99;">第3回合結果:b[]=1,3,5,8,9 </span></p> <hr /> <p><br /><span style="background-color: #ffff99;">排序後 b[]=1,3,5,8,9</span></p> <p>&nbsp;</p> <p><span style="background-color: #ccffff;"><br /></span></p> <p><span style="background-color: #ffff99;"><span class="external text">REF1: </span><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=532&amp;blogId=70">20191116用dev C++來編寫氣泡、選擇、插入排序法</a></span></p> <p><span style="background-color: #ffff99;">REF2: <a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=527&amp;blogId=70">20191111用python設計氣泡排序法(採升序排列,ascending)</a></span></p> <p><span style="background-color: #ffff99;">REF3:<a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=555&amp;blogId=70">20191230用JavaScript設計插入與選擇排序法</a></span></p> 一般 2020-06-19T20:39:48Z tree 20200616用python來可輸入產生費氏數列的程式 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=601&blogId=70 <p>(一)費氏數列由0和1開始,之後的費氏數字就是由之前的兩數相加而得出。</p> <p>(1-1)首幾個費氏數字是: <a title="0" href="https://zh.wikipedia.org/wiki/0">0</a>, <a title="1" href="https://zh.wikipedia.org/wiki/1">1</a>, <a title="1" href="https://zh.wikipedia.org/wiki/1">1</a>, <a title="2" href="https://zh.wikipedia.org/wiki/2">2</a>, <a title="3" href="https://zh.wikipedia.org/wiki/3">3</a>, <a title="5" href="https://zh.wikipedia.org/wiki/5">5</a>, <a title="8" href="https://zh.wikipedia.org/wiki/8">8</a>, <a title="13" href="https://zh.wikipedia.org/wiki/13">13</a>, <a title="21" href="https://zh.wikipedia.org/wiki/21">21</a>, <a title="34" href="https://zh.wikipedia.org/wiki/34">34</a>, <a title="55" href="https://zh.wikipedia.org/wiki/55">55</a>, <a title="89" href="https://zh.wikipedia.org/wiki/89">89</a>, <a title="144" href="https://zh.wikipedia.org/wiki/144">144</a>, <a title="233" href="https://zh.wikipedia.org/wiki/233">233</a>&hellip;&hellip;(參考維基百科)</p> <p>(1-2)第n個費氏數字及第n-1個費氏數字的比例趨近於黃金比例(1.618...)。</p> <p>&nbsp;</p> <p>(二)編寫python程式:</p> <p>(2-1)由windows開始功能表執行 IDLE(python 3.7 64bit)</p> <p><span class="external text">&nbsp;&nbsp;&nbsp; 安裝python請參考:</span><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=514&amp;blogId=70">20191014在windows7安裝並使用python3.7.4來剖析數字序列字串</a></p> <p><span style="background-color: #ffffff;">(2-2)按CTRL+N在PYTHON文字編輯器編寫如下程式碼,並存為 d:\fib-1.py</span></p> <p><span style="background-color: #ccffcc;">def fib(n):<br />&nbsp;&nbsp;&nbsp; if n&lt;=1 :<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return n<br />&nbsp;&nbsp;&nbsp; else:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return fib(n-1)+fib(n-2)<br />&nbsp;&nbsp;&nbsp; <br />n=int(input("請輸入n="))<br />while n &gt;= 0 :<br />&nbsp; &nbsp; print(<span>fib(n)</span>)<br />&nbsp;&nbsp;&nbsp; n=int(input("請再輸入n="))</span></p> <p><span style="background-color: #ffffff;">&nbsp;</span></p> <p><span style="background-color: #ffffff;">(2-3)在PYTHON文字編輯器按F5可儲存編寫的程式碼並執行之,結果如下:</span></p> <p><span style="background-color: #ccffcc;">請輸入數字n=0</span><br /><span style="background-color: #ccffcc;">fib( 0 )= 0</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=1</span><br /><span style="background-color: #ccffcc;">fib( 1 )= 1</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=2</span><br /><span style="background-color: #ccffcc;">fib( 2 )= 1</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=3</span><br /><span style="background-color: #ccffcc;">fib( 3 )= 2</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=4</span><br /><span style="background-color: #ccffcc;">fib( 4 )= 3</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=5</span><br /><span style="background-color: #ccffcc;">fib( 5 )= 5</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=6</span><br /><span style="background-color: #ccffcc;">fib( 6 )= 8</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=7</span><br /><span style="background-color: #ccffcc;">fib( 7 )= 13</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=8</span><br /><span style="background-color: #ccffcc;">fib( 8 )= 21</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=9</span><br /><span style="background-color: #ccffcc;">fib( 9 )= 34</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=10</span><br /><span style="background-color: #ccffcc;">fib( 10 )= 55</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=11</span><br /><span style="background-color: #ccffcc;">fib( 11 )= 89</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=12</span><br /><span style="background-color: #ccffcc;">fib( 12 )= 144</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=13</span><br /><span style="background-color: #ccffcc;">fib( 13 )= 233</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=14</span><br /><span style="background-color: #ccffcc;">fib( 14 )= 377</span><br /><span style="background-color: #ccffcc;">請再輸入另一個n=-1</span></p> <p><span style="background-color: #ccffcc;"><br /></span></p> <p>(三)編寫python程式:</p> <p><span style="background-color: #ffffff;">(3-1)按CTRL+N在PYTHON文字編輯器編寫如下程式碼,並存為 d:\fib-2.py</span></p> <p><span style="background-color: #ffffff;"><span style="background-color: #ffff99;">def fib(n):</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; if n&lt;=1 :</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return n</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; else:</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return fib(n-1)+fib(n-2)</span><br />&nbsp;&nbsp;&nbsp; <br /><span style="background-color: #ffff99;">n=int(input("請輸入數字n="))</span><br /><span style="background-color: #ffff99;">cs = [] </span><br /><span style="background-color: #ffff99;">while n &gt;= 0 :</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; x=fib(n)</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; print("fib(",n,")=",x)</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; cs.append(x)</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; print ("cs[]=",cs)</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; n=int(input("請再輸入另一個n="))</span><br />&nbsp;&nbsp;&nbsp; <br />(3-2)在PYTHON文字編輯器按F5可儲存編寫的程式碼並執行之,結果如下:</span></p> <p><span style="background-color: #ffff99;">請輸入數字n=0<br />fib( 0 )= 0<br />cs[]= [0]<br />請再輸入另一個n=1<br />fib( 1 )= 1<br />cs[]= [0, 1]<br />請再輸入另一個n=2<br />fib( 2 )= 1<br />cs[]= [0, 1, 1]<br />請再輸入另一個n=3<br />fib( 3 )= 2<br />cs[]= [0, 1, 1, 2]<br />請再輸入另一個n=4<br />fib( 4 )= 3<br />cs[]= [0, 1, 1, 2, 3]<br />請再輸入另一個n=5<br />fib( 5 )= 5<br />cs[]= [0, 1, 1, 2, 3, 5]<br />請再輸入另一個n=6<br />fib( 6 )= 8<br />cs[]= [0, 1, 1, 2, 3, 5, 8]<br />請再輸入另一個n=7<br />fib( 7 )= 13<br />cs[]= [0, 1, 1, 2, 3, 5, 8, 13]<br />請再輸入另一個n=8<br />fib( 8 )= 21<br />cs[]= [0, 1, 1, 2, 3, 5, 8, 13, 21]<br />請再輸入另一個n=9<br />fib( 9 )= 34<br />cs[]= [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]<br />請再輸入另一個n=-1</span></p> <p><span style="background-color: #ffffff;"><br /></span></p> 一般 2020-06-16T20:50:54Z tree 20200604用DEV-C++設計C++STL堆疊及佇列程式 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=598&blogId=70 <p>如沒有DEV-C++ C語言編譯開發環境(SDK),請先下載<a href="https://zh-tw.osdn.net/projects/sfnet_orwelldevcpp/downloads/Setup%20Releases/Dev-Cpp%205.11%20TDM-GCC%204.9.2%20Setup.exe/">Dev-Cpp 5.11 TDM-GCC 4.9.2 Setup.exe</a>(約49MB)並安裝之</p> <p>(一)C++ STL堆疊程式:</p> <p><span style="background-color: #ccffff;">(1-0) 堆疊資料結構,只能自頂端推入(PUSH)元素,也只能自頂端移走(POP)元素,先進後出。</span></p> <p>(1-1)例子:</p> <p>將如下3數1、2、3依序推入堆疊S中,再自S取出二個,</p> <p>再將4、5、6依序推入堆疊S中,再自S取出1個,</p> <p>再將7、8、9依序推入堆疊S中,再自S取出2個,</p> <p>最後的S為何?&nbsp; 答:「頂端:7 5 4 1」</p> <p>會依序取出的數為何?&nbsp; 答:「3 2 6 9 8」</p> <p><br />(1-2)執行DEV-C++並按CTRL+N編寫如下程式碼並存為 <span style="background-color: #ccffff;">d:\s1.cpp</span></p> <p>&nbsp;</p> <p><span style="background-color: #ccffcc;">#include &lt;stack&gt;<br />#include &lt;iostream&gt;<br />using namespace std;<br />int main(){<br />&nbsp;&nbsp;&nbsp; stack&lt;int&gt; s;<br />&nbsp;&nbsp;&nbsp; printf("\n推入10個立方數到堆疊s中:\n&lt;s底端:");<br />&nbsp;&nbsp;&nbsp; for (int i=0;i&lt;10;i++) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int x=i*i*i;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%3d : ",x);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s.push(x);<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; printf(":s頂端&gt;\n將堆疊s中的數一一取出如下:\n");<br />&nbsp;&nbsp;&nbsp; while (not s.empty()){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int y=s.top();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("將s頂端元素(%3d)取出前, s有%3d個元素&nbsp; \n", y,s.size()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s.pop();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; }<br />}</span></p> <p><span style="background-color: #ccffcc;"><br /></span></p> <p><span style="background-color: #ffffff;">(1-3)按F11編譯並執行s1.cpp,會於新視窗上輸出結果如下: </span></p> <p><br /><span style="background-color: #ffff99;">推入10個立方數到堆疊s中:</span><br /><span style="background-color: #ffff99;">&lt;s底端:&nbsp; 0 :&nbsp;&nbsp; 1 :&nbsp;&nbsp; 8 :&nbsp; 27 :&nbsp; 64 : 125 : 216 : 343 : 512 : 729 : :s頂端&gt;</span><br /><span style="background-color: #ffff99;">將堆疊s中的數一一取出如下:</span><br /><span style="background-color: #ffff99;">將s頂端元素(729)取出前, s有 10個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素(512)取出前, s有&nbsp; 9個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素(343)取出前, s有&nbsp; 8個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素(216)取出前, s有&nbsp; 7個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素(125)取出前, s有&nbsp; 6個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素( 64)取出前, s有&nbsp; 5個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素( 27)取出前, s有&nbsp; 4個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素(&nbsp; 8)取出前, s有&nbsp; 3個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素(&nbsp; 1)取出前, s有&nbsp; 2個元素</span><br /><span style="background-color: #ffff99;">將s頂端元素(&nbsp; 0)取出前, s有&nbsp; 1個元素</span></p> <p>(1-4)按CTRL+N編寫如下程式碼並存為&nbsp;<span>d:\s2.cpp</span></p> <p><span style="background-color: #ffff99;">#include &lt;stack&gt;</span></p> <p><span style="background-color: #ffff99;">#include &lt;iostream&gt;</span></p> <p><span style="background-color: #ffff99;">using namespace std;</span></p> <p><span style="background-color: #ffff99;">int main(){&nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">stack&lt;int&gt; s;&nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("\n推入1,2,3\n");&nbsp;&nbsp;</span><span style="background-color: #ffff99;">s.push(1);&nbsp; &nbsp;</span><span style="background-color: #ffff99;">s.push(2);&nbsp; &nbsp;</span><span style="background-color: #ffff99;">s.push(3);&nbsp; &nbsp; &nbsp;&nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.top());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /></span><span style="background-color: #ffff99;">printf("取出(%d)\n", s.top());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("\n推入4,5,6\n");&nbsp; &nbsp;s.push(4);&nbsp; &nbsp;s.push(5);&nbsp; &nbsp;s.push(6);&nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.top());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("\n推入7,8,9\n");&nbsp; &nbsp;s.push(7);&nbsp; &nbsp;s.push(8);&nbsp; &nbsp;s.push(9);&nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.top());&nbsp; &nbsp;s.pop();&nbsp;&nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.top());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></p> <p><span style="background-color: #ffff99;">}</span></p> <p>(1-5)按F11編譯並執行s2.cpp,會於新視窗上輸出結果如下:</p> <p><br /><span style="background-color: #ffff00;">推入1,2,3<br />取出(3)<br />取出(2)</span><br /><span style="background-color: #ffff00;">推入4,5,6<br />取出(6)</span><br /><span style="background-color: #ffff00;">推入7,8,9<br />取出(9)<br />取出(8)</span></p> <p>(二)C++ STL佇列程式:</p> <p><span style="background-color: #ccffff;">(2-0) 佇列資料結構,自後端推入(PUSH)元素,自前端移走(POP)元素,先進先出。</span></p> <p>(2-1)例子:&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>將如下3數1、2、3依序自後端推入佇列Q中,再自Q前端取出二個,</p> <p>再將4、5、6依序推入佇列Q中,再自Q取出1個,</p> <p>再將7、8、9依序推入佇列中,再自Q取出2個,</p> <p>最後的Q為何?&nbsp; 答:「後端: 9&nbsp; 8 7 6&nbsp; :前端」</p> <p>會依序取出的數為何?&nbsp; 答:「1 2 3 4 5」</p> <p><br />(2-2)執行DEV-C++並按CTRL+N編寫如下程式碼並存為 <span style="background-color: #ccffff;">d:\q1.cpp</span></p> <p><span style="background-color: #ffff99;">#include &lt;queue&gt;</span><br /><span style="background-color: #ffff99;">#include &lt;iostream&gt;</span><br /><span style="background-color: #ffff99;">using namespace std;</span><br /><span style="background-color: #ffff99;">int main(){</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; queue&lt;int&gt; q; </span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; printf("\n插入10個平方數到佇列q中:\n &lt;q前端:");</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; for (int i=0;i&lt;10;i++) {</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int x=i*i;</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf("%3d : ",x);</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; q.push(x);</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; printf(":q後端&gt;\n將q中元素一一自前端取出如下:\n");</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; while (not q.empty()){</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int y=q.front();</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf("將q最前端元素(%2d)取出前, q有%2d個元素\n",y,q.size());&nbsp; </span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; q.pop();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; }</span><br /><span style="background-color: #ffff99;">&nbsp;&nbsp;&nbsp; printf("q.size()=%d\n",q.size());</span><br /><span style="background-color: #ffff99;">}</span></p> <p><span style="background-color: #ffffff;">(2-3)按F11編譯並執行q1.cpp,會於新視窗上輸出結果如下: </span></p> <p><span style="background-color: #ffff99;"><br /><span style="background-color: #ccffff;">插入10個平方數到佇列q中:<br />&nbsp;&lt;q前端:&nbsp; 0 :&nbsp;&nbsp; 1 :&nbsp;&nbsp; 4 :&nbsp;&nbsp; 9 :&nbsp; 16 :&nbsp; 25 :&nbsp; 36 :&nbsp; 49 :&nbsp; 64 :&nbsp; 81 : :q後端&gt;<br />將q中元素一一自前端取出如下:<br />將q最前端元素( 0)取出前, q有10個元素<br />將q最前端元素( 1)取出前, q有 9個元素<br />將q最前端元素( 4)取出前, q有 8個元素<br />將q最前端元素( 9)取出前, q有 7個元素<br />將q最前端元素(16)取出前, q有 6個元素<br />將q最前端元素(25)取出前, q有 5個元素<br />將q最前端元素(36)取出前, q有 4個元素<br />將q最前端元素(49)取出前, q有 3個元素<br />將q最前端元素(64)取出前, q有 2個元素<br />將q最前端元素(81)取出前, q有 1個元素<br />q.size()=0</span></span></p> <p>&nbsp;</p> <p>(2-4)執行DEV-C++並按CTRL+N編寫如下程式碼並存為&nbsp;<span>d:\q2.cpp</span></p> <div><span style="background-color: #ffff99;">#include &lt;queue&gt;</span></div> <p><span style="background-color: #ffff99;">#include &lt;iostream&gt; </span></p> <p><span style="background-color: #ffff99;">using namespace std; </span></p> <p><span style="background-color: #ffff99;">int main(){ &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">queue&lt;int&gt; s; &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("\n推入1,2,3\n"); &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">s.push(1);&nbsp; &nbsp;s.push(2);&nbsp; &nbsp;s.push(3); &nbsp; &nbsp; &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.front());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.front());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("\n推入4,5,6\n"); &nbsp; &nbsp;s.push(4);&nbsp; &nbsp;s.push(5);&nbsp; &nbsp;s.push(6); &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.front());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("\n推入7,8,9\n"); &nbsp; &nbsp;s.push(7);&nbsp; &nbsp;s.push(8);&nbsp; &nbsp;s.push(9); &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.front());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp;</span></p> <p><span style="background-color: #ffff99;">printf("取出(%d)\n", s.front());&nbsp; &nbsp;s.pop();&nbsp; &nbsp; &nbsp; </span></p> <p><span style="background-color: #ffff99;">}</span></p> <p><span style="background-color: #ffff99;">(2-5)按F11編譯並執行q2.cpp,會於新視窗上輸出結果如下:</span></p> <p><span style="background-color: #ffff99;"><br />推入1,2,3<br /></span>取出(1)<br />取出(2)</p> <p>推入4,5,6<br />取出(3)<br />推入7,8,9<br />取出(4)<br />取出(5)</p> <p><span style="background-color: #ffff99;"></span></p> <p><span style="background-color: #ffff99;"><br /></span></p> <p><span style="background-color: #ffff99;">REF1: </span><a href="https://larry850806.github.io/2016/06/06/STL1/">https://larry850806.github.io/2016/06/06/STL1/</a></p> <ul> <li><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=539&amp;blogId=70">20191125用DEV-C++設計各式資料型態的陣列</a> </li> </ul> 一般 2020-06-04T21:43:30Z tree 20200529在UBuntu Linux 安裝並使用gcc10.1來編寫1個C程式 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=596&blogId=70 <p>參考(<a href="https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/">https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/</a>)</p> <p>&nbsp;下載</p> <table> <tbody> <tr> <td valign="top"><img src="https://bigsearcher.com/icons/compressed.gif" alt="[ ]" /></td> <td><a href="https://bigsearcher.com/mirrors/gcc/releases/gcc-10.1.0/gcc-10.1.0.tar.gz">gcc-10.1.0.tar.gz</a></td> <td align="right">2020-05-07 04:14</td> <td align="right">125M</td> <td>&nbsp;</td> </tr> </tbody> </table> <p>(一)在32位元LINUX</p> <p>(1)</p> <p>$ sudo apt update<br />[sudo] password for treehrt: <br />略過:1 http://dl.google.com/linux/earth/deb stable InRelease<br />下載:2 http://dl.google.com/linux/earth/deb stable Release [933 B]<br />下載:3 http://dl.google.com/linux/earth/deb stable Release.gpg [819 B]<br />略過:3 http://dl.google.com/linux/earth/deb stable Release.gpg<br />已有:4 http://tw.archive.ubuntu.com/ubuntu xenial InRelease&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:5 http://tw.archive.ubuntu.com/ubuntu xenial-updates InRelease&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:6 http://tw.archive.ubuntu.com/ubuntu xenial-backports InRelease&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:7 http://security.ubuntu.com/ubuntu xenial-security InRelease&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:8 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial InRelease<br />已有:9 http://ppa.launchpad.net/ubuntuhandbook1/audacity/ubuntu xenial InRelease<br />正在讀取套件清單... 完成&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />W: GPG 錯誤: http://dl.google.com/linux/earth/deb stable Release: 由於無法取得它們的公鑰,以下簽章無法進行驗證: NO_PUBKEY 78BD65473CB3BD13<br />E: The repository 'http://dl.google.com/linux/earth/deb stable Release' is not signed.<br />N: Updating from such a repository can't be done securely, and is therefore disabled by default.<br />N: See apt-secure(8) manpage for repository creation and user configuration details.<br />treehrt ~$</p> <p>&nbsp;</p> <p>(2)<code class="language-console"><span class="go">$sudo apt upgrade</span></code><br /><code class="language-console"><span class="go">:</span></code></p> <p><span class="go">找到 Windows 7 (loader) [於 /dev/sda1]<br />找到 Windows Recovery Environment (loader) [於 /dev/sda2]<br />找到 Windows 7 (loader) [於 /dev/sda3]<br />找到 Fedora release 19 (Schr&ouml;dinger&rsquo;s Cat) [於 /dev/mapper/fedora-root]<br />完成<br />treehrt ~$ </span></p> <p><span class="go"><br /></span></p> <p>花很久的時間&hellip;終於昇級完成。</p> <p>&nbsp;</p> <p>(3)</p> <p><span class="go">&nbsp;sudo apt install build-essential wget m4 flex bison<br />[sudo] password for treehrt: <br />正在讀取套件清單... 完成<br />正在重建相依關係&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />正在讀取狀態資料... 完成<br />bison is already the newest version (2:3.0.4.dfsg-1).<br />build-essential is already the newest version (12.1ubuntu2).<br />flex is already the newest version (2.6.0-11).<br />m4 is already the newest version (1.4.17-5).<br />m4 被設定為手動安裝。<br />wget is already the newest version (1.17.1-1ubuntu1.5).<br />以下套件為自動安裝,並且已經無用:<br />&nbsp; liblilv-0-0 libllvm5.0 libqpdf17 libserd-0-0 libsord-0-0 libsratom-0-0<br />&nbsp; libsuil-0-0 linux-headers-4.4.0-121 linux-headers-4.4.0-121-generic<br />&nbsp; linux-headers-4.4.0-96 linux-headers-4.4.0-96-generic<br />&nbsp; linux-image-4.4.0-121-generic linux-image-4.4.0-96-generic<br />&nbsp; linux-image-extra-4.4.0-121-generic linux-image-extra-4.4.0-96-generic<br />&nbsp; snapd-login-service<br />Use 'sudo apt autoremove' to remove them.<br />升級 0 個,新安裝 0 個,移除 0 個,有 0 個未被升級。<br />treehrt ~$ <br /><br /></span></p> <p><span class="go">(4) </span></p> <p><span class="go">treehrt ~$ tar xvzf gcc-10.1.0.tar.gz </span></p> <p><span class="go">treehrt ~$ cd gcc-10.1.0/</span></p> <p><span class="go">(5)</span></p> <p><span class="go">treehrt ~/gcc-10.1.0$ contrib/download_prerequisites<br />2020-05-29 21:55:05 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840/2383840] -&gt; "./gmp-6.1.0.tar.bz2" [1]<br />2020-05-29 21:55:07 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284/1279284] -&gt; "./mpfr-3.1.4.tar.bz2" [1]<br />2020-05-29 21:55:09 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925/669925] -&gt; "./mpc-1.0.3.tar.gz" [1]<br />2020-05-29 21:55:11 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291/1658291] -&gt; "./isl-0.18.tar.bz2" [1]<br />gmp-6.1.0.tar.bz2: 正確<br />mpfr-3.1.4.tar.bz2: 正確<br />mpc-1.0.3.tar.gz: 正確<br />isl-0.18.tar.bz2: 正確<br />All prerequisites downloaded successfully.<br />treehrt ~/gcc-10.1.0$ <br /></span></p> <p><span class="go"><br /></span></p> <p>(6)</p> <p>$ mkdir gcc10build<br />treehrt ~$ cd gcc10build/<br />treehrt ~/gcc10build$ uname -a<br />Linux treehrt-BM6AE-BM1AE-BP1AE 4.20.0 #1 SMP Sat Jan 5 13:21:51 CST 2019 i686 i686 i686 GNU/Linux<br />treehrt ~/gcc10build$</p> <p>(7)</p> <p>treehrt ~/gcc10build$ ../gcc-10.1.0/configure -v --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --prefix=/usr/local/gcc-10.1.0 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --program-suffix=-10.1</p> <p>&nbsp;</p> <p>(8)</p> <p>treehrt ~/gcc10build$ lscpu<br />Architecture:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i686<br />CPU 作業模式:&nbsp;&nbsp;&nbsp; 32-bit, 64-bit<br />Byte Order:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Little Endian<br />CPU(s):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8<br />On-line CPU(s) list:&nbsp;&nbsp; 0-7<br />每核心執行緒數:2<br />每通訊端核心數:4<br />Socket(s):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br />供應商識別號:&nbsp; GenuineIntel<br />CPU 家族:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6<br />型號:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 60<br />Model name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz<br />製程:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3<br />CPU MHz:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1196.072<br />CPU max MHz:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4000.0000<br />CPU min MHz:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 800.0000<br />BogoMIPS:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7183.48<br />虛擬:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VT-x<br />L1d 快取:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32K<br />L1i 快取:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32K<br />L2 快取:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 256K<br />L3 快取:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8192K<br />Flags:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts flush_l1d<br />treehrt ~/gcc10build$</p> <p>(9)</p> <p>treehrt ~/gcc10build$ make -j 16</p> <p>:</p> <p>libtool: link: ranlib .libs/libgfortran.a<br />libtool: link: rm -fr .libs/libgfortran.lax .libs/libgfortran.lax<br />libtool: link: ( cd ".libs" &amp;&amp; rm -f "libgfortran.la" &amp;&amp; ln -s "../libgfortran.la" "libgfortran.la" )<br />make[3]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libgfortran'<br />make[2]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libgfortran'<br />make[1]: Leaving directory '/home/treehrt/gcc10build'<br />treehrt ~/gcc10build$</p> <p>(10)</p> <p>treehrt ~/gcc10build$ sudo make install-strip</p> <p>\:</p> <p>----------------------------------------------------------------------<br />Libraries have been installed in:<br />&nbsp;&nbsp; /usr/local/gcc-10.1.0/lib<br /><br />If you ever happen to want to link against installed libraries<br />in a given directory, LIBDIR, you must either use libtool, and<br />specify the full pathname of the library, or use the `-LLIBDIR'<br />flag during linking and do at least one of the following:<br />&nbsp;&nbsp; - add LIBDIR to the `LD_LIBRARY_PATH' environment variable<br />&nbsp;&nbsp;&nbsp;&nbsp; during execution<br />&nbsp;&nbsp; - add LIBDIR to the `LD_RUN_PATH' environment variable<br />&nbsp;&nbsp;&nbsp;&nbsp; during linking<br />&nbsp;&nbsp; - use the `-Wl,-rpath -Wl,LIBDIR' linker flag<br />&nbsp;&nbsp; - have your system administrator add LIBDIR to `/etc/ld.so.conf'<br /><br />See any operating system documentation about shared libraries for<br />more information, such as the ld(1) and ld.so(8) manual pages.<br />----------------------------------------------------------------------<br />make[5]: Nothing to be done for 'install-data-am'.<br />make[5]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[4]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[3]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[2]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[1]: Leaving directory '/home/treehrt/gcc10build'<br />treehrt ~/gcc10build$</p> <p>&nbsp;</p> <p>(11)</p> <p>treehrt ~/gcc10build$ export export PATH=/usr/local/gcc-10.1.0/bin:$PATH<br />treehrt ~/gcc10build$ export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH</p> <p>&nbsp;</p> <p>(12)</p> <p>treehrt ~$ vi t1.c</p> <p>treehrt ~$ cat t1.c<br />#include &lt;iostream&gt;<br />int main() {<br />&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; [](auto a, auto b) { return a + b; } (5, 6) &lt;&lt; std::endl;<br />&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; [](auto a, auto b) { return a + b; } (5.23, 6.45) &lt;&lt; std::endl;<br />&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br />}<br />treehrt ~$ g++-10.1 -Wall -pedantic t1.c -o t1<br />treehrt ~$ ./t1<br />11<br />11.68</p> <p>&nbsp;</p> <p>(二)在64位元LINUX</p> <p>(2-1)</p> <p>$ gcc -v<br />Using built-in specs.<br />COLLECT_GCC=gcc<br />COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper<br />Target: x86_64-linux-gnu<br />Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu<br />Thread model: posix<br />gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) <br />treehrt@Jason-System-Product-Name:~$</p> <p>(2-2)</p> <p>$ sudo apt update<br />[sudo] password for treehrt: <br />Sorry, try again.<br />[sudo] password for treehrt: <br />Sorry, try again.<br />[sudo] password for treehrt: <br />已有:1 http://dl.google.com/linux/chrome/deb stable InRelease<br />略過:2 http://dl.google.com/linux/earth/deb stable InRelease&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:3 http://dl.google.com/linux/earth/deb stable Release&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:5 http://tw.archive.ubuntu.com/ubuntu xenial InRelease&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:6 http://tw.archive.ubuntu.com/ubuntu xenial-updates InRelease&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:7 http://tw.archive.ubuntu.com/ubuntu xenial-backports InRelease&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />已有:8 http://security.ubuntu.com/ubuntu xenial-security InRelease&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />正在讀取套件清單... 完成&nbsp;&nbsp;&nbsp; <br />正在重建相依關係&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />正在讀取狀態資料... 完成<br />86 packages can be upgraded. Run 'apt list --upgradable' to see them.<br />N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'http://dl.google.com/linux/earth/deb stable InRelease' doesn't support architecture 'i386'<br />treehrt@Jason-System-Product-Name:~$</p> <p>(2-3)<span class="go">treehrt@Jason-System-Product-Name:~$ sudo apt upgrade</span></p> <p><span class="go">:<br /><br /></span></p> <p><span class="go">設定 unattended-upgrades (1.1ubuntu1.18.04.7~16.04.6) ...<br />安裝新版的設定檔 /etc/kernel/postinst.d/unattended-upgrades ...<br />安裝新版的設定檔 /etc/pm/sleep.d/10_unattended-upgrades-hibernate ...<br />Replacing config file /etc/apt/apt.conf.d/50unattended-upgrades with new version<br />設定 usb-creator-common (0.3.2ubuntu16.04.2) ...<br />設定 usb-creator-gtk (0.3.2ubuntu16.04.2) ...<br />設定 xdg-desktop-portal (1.0.3-0ubuntu0.0) ...<br />設定 xdg-desktop-portal-gtk (1.0.2-0ubuntu0.0) ...<br />設定 lsb-invalid-mta (9.20160110ubuntu0.2) ...<br />設定 lsb-security (9.20160110ubuntu0.2) ...<br />設定 lsb-core (9.20160110ubuntu0.2) ...<br />設定 python3-distupgrade (1:16.04.30) ...<br />設定 python3-update-manager (1:16.04.17) ...<br />設定 ubuntu-release-upgrader-core (1:16.04.30) ...<br />安裝新版的設定檔 /etc/update-manager/meta-release ...<br />設定 update-manager-core (1:16.04.17) ...<br />設定 ubuntu-release-upgrader-gtk (1:16.04.30) ...<br />設定 update-manager (1:16.04.17) ...<br />Processing triggers for gconf2 (3.2.6-3ubuntu6) ...<br />設定 ubuntu-desktop (1.361.4) ...<br />Processing triggers for libc-bin (2.23-0ubuntu11) ...<br />Processing triggers for shim-signed (1.33.1~16.04.5+15+1533136590.3beb971-0ubuntu1) ...<br />Processing triggers for initramfs-tools (0.122ubuntu8.16) ...<br />update-initramfs: Generating /boot/initrd.img-4.15.0-101-generic<br />W: Possible missing firmware /lib/firmware/i915/kbl_guc_ver9_14.bin for module i915<br />W: Possible missing firmware /lib/firmware/i915/bxt_guc_ver8_7.bin for module i915<br />Processing triggers for resolvconf (1.78ubuntu7) ...</span></p> <p><span class="go">(2-4)treehrt@Jason-System-Product-Name:~$ sudo apt install build-essential wget m4 flex bison<br />正在讀取套件清單... 完成<br />正在重建相依關係&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />正在讀取狀態資料... 完成<br />build-essential is already the newest version (12.1ubuntu2).<br />m4 is already the newest version (1.4.17-5).<br />m4 被設定為手動安裝。<br />wget is already the newest version (1.17.1-1ubuntu1.5).<br />以下套件為自動安裝,並且已經無用:<br />&nbsp; linux-headers-4.15.0-45 linux-headers-4.15.0-45-generic linux-headers-4.15.0-65 linux-headers-4.15.0-65-generic linux-headers-4.15.0-66 linux-headers-4.15.0-66-generic linux-headers-4.15.0-72<br />&nbsp; linux-headers-4.15.0-72-generic linux-headers-4.15.0-74 linux-headers-4.15.0-74-generic linux-headers-4.15.0-76 linux-headers-4.15.0-76-generic linux-headers-4.15.0-88 linux-headers-4.15.0-88-generic<br />&nbsp; linux-headers-4.15.0-91 linux-headers-4.15.0-91-generic linux-headers-4.15.0-96 linux-headers-4.15.0-96-generic linux-image-4.15.0-45-generic linux-image-4.15.0-65-generic<br />&nbsp; linux-image-4.15.0-66-generic linux-image-4.15.0-72-generic linux-image-4.15.0-74-generic linux-image-4.15.0-76-generic linux-image-4.15.0-88-generic linux-image-4.15.0-91-generic<br />&nbsp; linux-image-4.15.0-96-generic linux-modules-4.15.0-45-generic linux-modules-4.15.0-65-generic linux-modules-4.15.0-66-generic linux-modules-4.15.0-72-generic linux-modules-4.15.0-74-generic<br />&nbsp; linux-modules-4.15.0-76-generic linux-modules-4.15.0-88-generic linux-modules-4.15.0-91-generic linux-modules-4.15.0-96-generic linux-modules-extra-4.15.0-45-generic<br />&nbsp; linux-modules-extra-4.15.0-65-generic linux-modules-extra-4.15.0-66-generic linux-modules-extra-4.15.0-72-generic linux-modules-extra-4.15.0-74-generic linux-modules-extra-4.15.0-76-generic<br />&nbsp; linux-modules-extra-4.15.0-88-generic linux-modules-extra-4.15.0-91-generic linux-modules-extra-4.15.0-96-generic<br />Use 'sudo apt autoremove' to remove them.<br />下列的額外套件將被安裝:<br />&nbsp; libbison-dev libfl-dev<br />建議套件:<br />&nbsp; bison-doc<br />下列【新】套件將會被安裝:<br />&nbsp; bison flex libbison-dev libfl-dev<br />升級 0 個,新安裝 4 個,移除 0 個,有 0 個未被升級。<br />需要下載 900 kB 的套件檔。<br />此操作完成之後,會多佔用 2,692 kB 的磁碟空間。<br />是否繼續進行 [Y/n]? [Y/n] y</span></p> <p><span class="go">下載:1 http://tw.archive.ubuntu.com/ubuntu xenial/main amd64 libfl-dev amd64 2.6.0-11 [12.5 kB]<br />下載:2 http://tw.archive.ubuntu.com/ubuntu xenial/main amd64 flex amd64 2.6.0-11 [290 kB]<br />下載:3 http://tw.archive.ubuntu.com/ubuntu xenial/main amd64 libbison-dev amd64 2:3.0.4.dfsg-1 [338 kB]<br />下載:4 http://tw.archive.ubuntu.com/ubuntu xenial/main amd64 bison amd64 2:3.0.4.dfsg-1 [259 kB]<br />取得 900 kB 用了 0秒 (1,093 kB/s)<br />選取了原先未選的套件 libfl-dev:amd64。<br />(讀取資料庫 ... 目前共安裝了 552232 個檔案和目錄。)<br />準備解開 .../libfl-dev_2.6.0-11_amd64.deb ...<br />解開 libfl-dev:amd64 (2.6.0-11) 中...<br />選取了原先未選的套件 flex。<br />準備解開 .../flex_2.6.0-11_amd64.deb ...<br />解開 flex (2.6.0-11) 中...<br />選取了原先未選的套件 libbison-dev:amd64。<br />準備解開 .../libbison-dev_2%3a3.0.4.dfsg-1_amd64.deb ...<br />解開 libbison-dev:amd64 (2:3.0.4.dfsg-1) 中...<br />選取了原先未選的套件 bison。<br />準備解開 .../bison_2%3a3.0.4.dfsg-1_amd64.deb ...<br />解開 bison (2:3.0.4.dfsg-1) 中...<br />Processing triggers for libc-bin (2.23-0ubuntu11) ...<br />Processing triggers for install-info (6.1.0.dfsg.1-5) ...<br />Processing triggers for doc-base (0.10.7) ...<br />正在處理 1 added doc-base file...<br />Processing triggers for man-db (2.7.5-1) ...<br />設定 libfl-dev:amd64 (2.6.0-11) ...<br />設定 flex (2.6.0-11) ...<br />設定 libbison-dev:amd64 (2:3.0.4.dfsg-1) ...<br />設定 bison (2:3.0.4.dfsg-1) ...<br />update-alternatives: using /usr/bin/bison.yacc to provide /usr/bin/yacc (yacc) in auto mode<br />Processing triggers for libc-bin (2.23-0ubuntu11) ...<br />treehrt@Jason-System-Product-Name:~$ </span></p> <p><span class="go">(2-5)</span></p> <p><span class="go">$ wget https://bigsearcher.com/mirrors/gcc/releases/gcc-10.1.0/gcc-10.1.0.tar.gz</span></p> <p>$ tar xvzf gcc-10.1.0.tar.gz</p> <p>treehrt@Jason-System-Product-Name:~$ cd gcc-10.1.0/<br />treehrt@Jason-System-Product-Name:~/gcc-10.1.0$ contrib/download_prerequisites</p> <p>2020-05-31 08:16:05 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840/2383840] -&gt; "./gmp-6.1.0.tar.bz2" [1]<br />2020-05-31 08:16:07 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284/1279284] -&gt; "./mpfr-3.1.4.tar.bz2" [1]<br />2020-05-31 08:16:09 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925/669925] -&gt; "./mpc-1.0.3.tar.gz" [1]<br />2020-05-31 08:16:12 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291/1658291] -&gt; "./isl-0.18.tar.bz2" [1]<br />gmp-6.1.0.tar.bz2: 正確<br />mpfr-3.1.4.tar.bz2: 正確<br />mpc-1.0.3.tar.gz: 正確<br />isl-0.18.tar.bz2: 正確<br />All prerequisites downloaded successfully.<br />treehrt@Jason-System-Product-Name:~/gcc-10.1.0$</p> <p>(2-6)</p> <p><span style="background-color: #ffff99;">treehrt@Jason-System-Product-Name:~$ mkdir gcc10build<br />treehrt@Jason-System-Product-Name:~$ cd gcc10build/<br />treehrt@Jason-System-Product-Name:~/gcc10build$ ../gcc-10.1.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-10.1.0 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --program-suffix=-10.1</span></p> <p>:</p> <p><span style="background-color: #ffff99;">configure: creating ./config.status<br />config.status: creating Makefile<br /></span></p> <p><span style="background-color: #ffff99;">(2-7)</span></p> <p><span style="background-color: #ffff99;">treehrt@Jason-System-Product-Name:~/gcc10build$ lscpu<br /><span style="background-color: #ffffff;">Architecture:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x86_64</span><br /><span style="background-color: #ffffff;">CPU 作業模式:&nbsp;&nbsp;&nbsp; 32-bit, 64-bit</span><br /><span style="background-color: #ffffff;">Byte Order:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Little Endian</span><br /><span style="background-color: #ffffff;">CPU(s):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12</span><br /><span style="background-color: #ffffff;">On-line CPU(s) list:&nbsp;&nbsp; 0-11</span><br /><span style="background-color: #ffffff;">每核心執行緒數:2</span><br /><span style="background-color: #ffffff;">每通訊端核心數:6</span><br /><span style="background-color: #ffffff;">Socket(s):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1</span><br /><span style="background-color: #ffffff;">NUMA 節點:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1</span><br /><span style="background-color: #ffffff;">供應商識別號:&nbsp; GenuineIntel</span><br /><span style="background-color: #ffffff;">CPU 家族:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6</span><br /><span style="background-color: #ffffff;">型號:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 158</span><br /><span style="background-color: #ffffff;">Model name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz</span><br /><span style="background-color: #ffffff;">製程:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10</span><br /><span style="background-color: #ffffff;">CPU MHz:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 807.069</span><br /><span style="background-color: #ffffff;">CPU max MHz:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4600.0000</span><br /><span style="background-color: #ffffff;">CPU min MHz:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 800.0000</span><br /><span style="background-color: #ffffff;">BogoMIPS:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6384.00</span><br /><span style="background-color: #ffffff;">虛擬:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VT-x</span><br /><span style="background-color: #ffffff;">L1d 快取:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32K</span><br /><span style="background-color: #ffffff;">L1i 快取:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32K</span><br /><span style="background-color: #ffffff;">L2 快取:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 256K</span><br /><span style="background-color: #ffffff;">L3 快取:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12288K</span><br /><span style="background-color: #ffffff;">NUMA node0 CPU(s):&nbsp;&nbsp;&nbsp;&nbsp; 0-11</span><br /><span style="background-color: #ffffff;">Flags:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d</span><br /></span></p> <p><span style="background-color: #ffff99;">(2-8)<br />treehrt@Jason-System-Product-Name:~/gcc10build$ make -j 24</span></p> <p><span style="background-color: #ffff99;">:</span></p> <p><span style="background-color: #ffffff;">eehrt/gcc10build/./gcc/collect-ld" "LIBCFLAGS=-g -O2" "NM=/home/treehrt/gcc10build/./gcc/nm" "PICFLAG=" "RANLIB=x86_64-linux-gnu-ranlib" "DESTDIR=" DO=all multi-do # make<br />make[4]: Leaving directory '/home/treehrt/gcc10build/x86_64-linux-gnu/libsanitizer'<br />make[3]: Leaving directory '/home/treehrt/gcc10build/x86_64-linux-gnu/libsanitizer'<br />make[2]: Leaving directory '/home/treehrt/gcc10build/x86_64-linux-gnu/libsanitizer'<br />make[1]: Leaving directory '/home/treehrt/gcc10build'</span></p> <p><span style="background-color: #ffff99;">(2-9)</span></p> <p><span style="background-color: #ffffff;">treehrt@Jason-System-Product-Name:~$ cd gcc10build/<br />treehrt@Jason-System-Product-Name:~/gcc10build$ sudo make install-strip</span></p> <p><span style="background-color: #ffff99;"><span style="background-color: #ffff99;">(2-10)</span></span></p> <p><span style="background-color: #ffff99;"><span style="background-color: #ffff99;">treehrt@Jason-System-Product-Name:~/gcc10build$ export export PATH=/usr/local/gcc-10.1.0/bin:$PATH<br />treehrt@Jason-System-Product-Name:~/gcc10build$ export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH<br />treehrt@Jason-System-Product-Name:~/gcc10build$ gcc-10.1 -v<br /><span style="background-color: #ffffff;">使用內建 specs。</span><br /><span style="background-color: #ffffff;">COLLECT_GCC=gcc-10.1</span><br /><span style="background-color: #ffffff;">COLLECT_LTO_WRAPPER=/usr/local/gcc-10.1.0/libexec/gcc/x86_64-linux-gnu/10.1.0/lto-wrapper</span><br /><span style="background-color: #ffffff;">目的:x86_64-linux-gnu</span><br /><span style="background-color: #ffffff;">配置為:../gcc-10.1.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-10.1.0 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --program-suffix=-10.1</span><br /><span style="background-color: #ffffff;">執行緒模型:posix</span><br /><span style="background-color: #ffffff;">支援的 LTO 壓縮演算法:zlib</span><br /><span style="background-color: #ffffff;">gcc version 10.1.0 (GCC) </span></span></span></p> <p><span style="background-color: #ffff99;"><span style="background-color: #ffff99;"><span style="background-color: #ffffff;">&nbsp;</span><span style="background-color: #ffffff;">(2-11)</span></span></span></p> <p><span style="background-color: #ffff99;"><span style="background-color: #ffff99;"><span style="background-color: #ffffff;">$ vi t1.c<br />$ cat t1.c<br />#include &lt;iostream&gt;<br />int main() {<br />&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; [](auto a, auto b) { return a + b; } (5, 6) &lt;&lt; std::endl;<br />&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; [](auto a, auto b) { return a + b; } (5.23, 6.45) &lt;&lt; std::endl;<br />&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br />}<br /></span></span></span></p> <p><span style="background-color: #ffff99;"><span style="background-color: #ffff99;"><span style="background-color: #ffffff;">$ g++-10.1 -Wall -pedantic t1.c -o t1<br /></span></span></span></p> <p><span style="background-color: #ffff99;"><span style="background-color: #ffff99;"><span style="background-color: #ffffff;">$ ./t1<br />11<br />11.68<br /><br /></span></span></span></p> 一般 2020-05-29T20:49:07Z tree 20200529在LINUX安裝GCC10.1 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=595&blogId=70 <p>參考(<a href="https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/">https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/</a>)</p> <p>(1) 下載</p> <table> <tbody> <tr> <td valign="top"><img src="https://bigsearcher.com/icons/compressed.gif" alt="[ ]" /></td> <td><a href="https://bigsearcher.com/mirrors/gcc/releases/gcc-10.1.0/gcc-10.1.0.tar.gz">gcc-10.1.0.tar.gz</a></td> <td align="right">2020-05-07 04:14</td> <td align="right">125M</td> <td>&nbsp;</td> </tr> </tbody> </table> <p>&nbsp;</p> <p>(2)解開</p> <p># tar xvzf gcc-10.1.0.tar.gz</p> <p># cd gcc-10.1.0/</p> <p>(3)# <span style="background-color: #ffff99;">contrib/download_prerequisites</span><br />2020-05-27 11:01:17 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840/2383840] -&gt; "./gmp-6.1.0.tar.bz2" [1]<br />2020-05-27 11:01:20 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284/1279284] -&gt; "./mpfr-3.1.4.tar.bz2" [1]<br />2020-05-27 11:01:24 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925/669925] -&gt; "./mpc-1.0.3.tar.gz" [1]<br />2020-05-27 11:01:29 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291/1658291] -&gt; "./isl-0.18.tar.bz2" [1]<br />gmp-6.1.0.tar.bz2: 正確<br />mpfr-3.1.4.tar.bz2: 正確<br />mpc-1.0.3.tar.gz: 正確<br />isl-0.18.tar.bz2: 正確<br />All prerequisites downloaded successfully.</p> <p>&nbsp;</p> <p>(4)</p> <p>#<span style="background-color: #ffff99;"> cd ~webadm/lnx</span></p> <p><span style="background-color: #ffff99;">[root@www lnx]# mkdir gcc10build</span></p> <p><span style="background-color: #ffff99;">[root@www lnx]# cd gcc10build/</span></p> <p>&nbsp;</p> <p>(5)</p> <p>[root@www gcc10build]# ../gcc-10.1.0/configure -v --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --prefix=/usr/local/gcc-10.1.0 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --program-suffix=-10.1</p> <p>:</p> <p>configure: WARNING: using in-tree isl, disabling version check<br />*** This configuration is not supported in the following subdirectories:<br />&nbsp;&nbsp;&nbsp;&nbsp; gnattools gotools target-libada target-libhsail-rt target-libphobos target-zlib target-libgo target-libffi target-libobjc target-liboffloadmic<br />&nbsp;&nbsp;&nbsp; (Any other directories should still work fine.)</p> <p>:</p> <p>checking whether to enable maintainer-specific portions of Makefiles... no<br />configure: creating ./config.status<br />config.status: creating Makefile</p> <p>(6)<br /><span style="background-color: #ffff99;">[root@www gcc10build]# make</span></p> <p>libtool: link: ranlib .libs/libatomic.a<br />libtool: link: ( cd ".libs" &amp;&amp; rm -f "libatomic.la" &amp;&amp; ln -s "../libatomic.la" "libatomic.la" )<br />true&nbsp; DO=all multi-do # make<br />make[4]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[3]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[2]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[1]: Leaving directory `/home/webadm/lnx/gcc10build'</p> <p>(7)</p> <p>[root@www ~]# cd ~webadm/lnx/gcc10build/<br />[root@www gcc10build]# make install-strip</p> <p>:</p> <p>----------------------------------------------------------------------<br />Libraries have been installed in:<br />&nbsp;&nbsp; /usr/local/gcc-10.1.0/lib<br /><br />If you ever happen to want to link against installed libraries<br />in a given directory, LIBDIR, you must either use libtool, and<br />specify the full pathname of the library, or use the `-LLIBDIR'<br />flag during linking and do at least one of the following:<br />&nbsp;&nbsp; - add LIBDIR to the `LD_LIBRARY_PATH' environment variable<br />&nbsp;&nbsp;&nbsp;&nbsp; during execution<br />&nbsp;&nbsp; - add LIBDIR to the `LD_RUN_PATH' environment variable<br />&nbsp;&nbsp;&nbsp;&nbsp; during linking<br />&nbsp;&nbsp; - use the `-Wl,-rpath -Wl,LIBDIR' linker flag<br />&nbsp;&nbsp; - have your system administrator add LIBDIR to `/etc/ld.so.conf'<br /><br />See any operating system documentation about shared libraries for<br />more information, such as the ld(1) and ld.so(8) manual pages.<br />----------------------------------------------------------------------<br />make[5]: Nothing to be done for `install-data-am'.<br />make[5]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[4]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[3]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[2]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic'<br />make[1]: Leaving directory `/home/webadm/lnx/gcc10build'<br />[root@www gcc10build]#</p> <p>(8)</p> <p>[root@www gcc10build]# export export PATH=/usr/local/gcc-10.1.0/bin:$PATH<br />[root@www gcc10build]# export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH<br />[root@www gcc10build]#</p> <p>&nbsp;</p> <p>(9)用vi編寫如下t1.c程式並編譯執行成功:</p> <p>[root@www gcc10build]# vi t1.c</p> <p><br />[root@www gcc10build]# cat t1.c<br />#include &lt;iostream&gt;<br />int main() {<br />&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; [](auto a, auto b) { return a + b; } (5, 6) &lt;&lt; std::endl;<br />&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; [](auto a, auto b) { return a + b; } (5.23, 6.45) &lt;&lt; std::endl;<br />&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br />}</p> <p>[root@www gcc10build]# g++-10.1 -Wall -pedantic t1.c -o t1<br />[root@www gcc10build]# ./t1<br />11<br />11.68</p> <p>(10)用vi編寫如下t2.c程式並編譯執行成功:</p> <p>[root@www gcc10build]# ./t1<br />11<br />11.68<br />[root@www gcc10build]# vi t2.c<br />[root@www gcc10build]# cat t2.c<br />#include &lt;type_traits&gt;<br />#include &lt;iostream&gt;<br /><br />struct A {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int foo;<br />};<br /><br />struct B {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int foo = 0;<br />};<br /><br />template &lt;typename T&gt;<br />void print(const T&amp; a){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static_assert(std::is_pod&lt;T&gt;::value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; a.foo &lt;&lt; '\n';<br />}<br /><br />int main() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A x{1};<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B y{2};<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B z;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print&lt;A&gt;(x);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print&lt;B&gt;(y);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print&lt;B&gt;(z);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br />}<br />[root@www gcc10build]# g++-10.1 -Wall -pedantic t2.c -o t2<br />t2.c: In function 「void print(const T&amp;)」:<br />t2.c:14:32: 警告:「static_assert」 without a message only available with 「-std=c++17」 or 「-std=gnu++17」 [-Wpedantic]<br />&nbsp;&nbsp; 14 |&nbsp; static_assert(std::is_pod&lt;T&gt;::value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^~~~~<br />t2.c: In instantiation of 「void print(const T&amp;) [with T = B]」:<br />t2.c:24:13:&nbsp;&nbsp; required from here<br />t2.c:14:32: 錯誤:static assertion failed<br />[root@www gcc10build]#</p> <p>&nbsp;</p> <p>[root@www gcc10build]# g++-10.1 -Wall -pedantic t2.c -o t2<br />t2.c: In function 「void print(const T&amp;)」:<br />t2.c:14:32: 警告:「static_assert」 without a message only available with 「-std=c++17」 or 「-std=gnu++17」 [-Wpedantic]<br />&nbsp;&nbsp; 14 |&nbsp; static_assert(std::is_pod&lt;T&gt;::value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^~~~~<br />t2.c: In instantiation of 「void print(const T&amp;) [with T = B]」:<br />t2.c:24:13:&nbsp;&nbsp; required from here<br />t2.c:14:32: 錯誤:static assertion failed<br />[root@www gcc10build]# g++-10.1 -std=c++17 -Wall -pedantic t2.c -o t2<br />t2.c: In instantiation of 「void print(const T&amp;) [with T = B]」:<br />t2.c:24:13:&nbsp;&nbsp; required from here<br />t2.c:14:32: 錯誤:static assertion failed<br />&nbsp;&nbsp; 14 |&nbsp; static_assert(std::is_pod&lt;T&gt;::value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^~~~~</p> <p>&nbsp;</p> 一般 2020-05-29T15:26:58Z tree 20200526用python設計二元搜尋樹(Binary Search Tree) http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=594&blogId=70 <p>(一)二元搜尋樹說明:</p> <p>參考:<a href="http://www.csie.ntnu.edu.tw/~u91029/BinaryTree.html">http://www.csie.ntnu.edu.tw/~u91029/BinaryTree.html</a></p> <p>(1)樹資料結構由節點及分支所組存,樹由根節點往下生長,每個節點可有多個子樹(分支),二元樹每一個節點至多二個子樹。樹不能有廻路(即所有的分支皆以分開了,不可再相連),</p> <p>(2)二元搜尋樹:將比根節點值小的數放在左子樹(前方)中,將比根節點值大的數放在右子樹(後方)中。</p> <p>例如:將如下數字50,19,28,88,93,31,22依序加入一個空的根節點可建立一棵二元搜尋樹如下:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; / &nbsp;&nbsp; \ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19&nbsp;&nbsp;&nbsp;&nbsp; 88<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 28&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 93<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; /&nbsp; \<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; 22 &nbsp;&nbsp; 31 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>(3)中序走訪法(InOrder Traversal): 先走訪左子樹,再走訪根節點,再走訪右子樹。</p> <p><span style="background-color: #ffff99;">用本法走訪(2)中的樹結果如下:19, 22, 28, 31, 50, 88, 95</span></p> <p>(4)前序走訪法(PreOrder Traversal):先走訪根節點,再走訪左子樹,再走訪右子樹。</p> <p><span style="background-color: #ffff99;">用本法走訪(2)中的樹結果如下:<span style="background-color: #ffff99;">50, 19, 28, 22, 31, 88, 95</span></span></p> <p>(5)後序走訪法(PostOrder Traversal):先走訪左子樹,再走訪右子樹,再走訪根節點。</p> <p><span style="background-color: #ffff99;">用本法走訪(2)中的樹結果如下:<span style="background-color: #ffff99;"><span style="background-color: #ffff99;">22, 31, 28, 19, 95, 88, 50</span></span></span></p> <p>(二)PYTHON程式:</p> <p>(1)由windows開始功能表執行 IDLE(python 3.7 64bit)</p> <p><span class="external text">&nbsp;&nbsp;&nbsp; 安裝python請參考:</span><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=514&amp;blogId=70">20191014在windows7安裝並使用python3.7.4來剖析數字序列字串</a></p> <p><span style="background-color: #ffffff;">(2)按CTRL+N在PYTHON文字編輯器編寫如下程式碼,並存為 d:\tree.py</span></p> <p><span style="background-color: #ffff99;"><span style="background-color: #ccffff;">class treeNode:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp; def __init__(self, val):</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.val = val</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.left = None</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.right = None</span><br /><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp; def insertT(self, val):</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if val &lt;= self.val:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.left == None:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.left = treeNode(val)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.left.insertT(val)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.right == None:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.right = treeNode(val)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.right.insertT(val)</span><br /><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp; def inorderT(self, root):</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = []</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if root:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = self.inorderT(root.left)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.append(root.val)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = res + self.inorderT(root.right)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return res</span><br /><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp; def PreorderT(self, root):</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = []</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if root:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.append(root.val)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = res + self.PreorderT(root.left)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = res + self.PreorderT(root.right)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return res</span><br />&nbsp;&nbsp;&nbsp; <br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp; def PostorderT(self, root):</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = []</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if root:</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = self.PostorderT(root.left)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = res + self.PostorderT(root.right)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.append(root.val)</span><br /><span style="background-color: #ccffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return res</span><br /><br /><br /><span style="background-color: #ccffff;">root = treeNode(50)</span><br /><span style="background-color: #ccffff;">root.insertT(19)</span><br /><span style="background-color: #ccffff;">root.insertT(28)</span><br /><span style="background-color: #ccffff;">root.insertT(88)</span><br /><span style="background-color: #ccffff;">root.insertT(95)</span><br /><span style="background-color: #ccffff;">root.insertT(31)</span><br /><span style="background-color: #ccffff;">root.insertT(22)</span><br /><span style="background-color: #ccffff;"><br />print('中序:' , root.inorderT(root))<br />print('前序:' , root.PreorderT(root))<br />print('後序:' , root.PostorderT(root))</span><br /><br /></span>(3)在PYTHON文字編輯器按F5可儲存編寫的程式碼並執行之:</p> <p><span style="background-color: #ffff99;">中序: [19, 22, 28, 31, 50, 88, 95]<br />前序: [50, 19, 28, 22, 31, 88, 95]<br />後序: [22, 31, 28, 19, 95, 88, 50]<br /><br /></span></p> <p>&nbsp;</p> <p>&nbsp;</p> <p>(4)</p> <p>a = []</p> <p>for i in range(5):&nbsp; &nbsp;</p> <p><span style="white-space: pre;"> </span>x= input("x=")&nbsp; &nbsp;</p> <p><span style="white-space: pre;"> </span>a.append(x)</p> <p>print(a)</p> <p>&nbsp;</p> 一般 2020-05-26T05:02:55Z tree