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

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/smartyview.class.php on line 245
樹心幽徑 http://oldwww.kmvs.km.edu.tw/lf/index.php?blogId=70 tree 2020-07-12T17:18:53Z 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 20200525在90.2Fedora LINUX機器昇級PHP http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=593&blogId=70 <p>(1) 裝 MediaWiki 1.34 requires at least PHP version 7.2.9, you are using PHP 5.4.5.</p> <p>&nbsp;</p> <p>(2)要先安裝並昇級gcc編譯器,安裝過程請參考<a title="Next post: 20200529在LINUX安裝GCC10.1" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=595&amp;blogId=70">20200529在LINUX安裝GCC10.1 &raquo;</a></p> <p>[root@www cmake-3.17.2]#&nbsp; export export PATH=/usr/local/gcc-10.1.0/bin:$PATH<br />[root@www cmake-3.17.2]#&nbsp; export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH</p> <p>&nbsp;</p> <p>(3)下載並安裝 <a href="https://libzip.org/download/libzip-1.6.1.tar.gz">libzip-1.6.1.tar.gz</a></p> <p>&nbsp;</p> <p>(4)下載<a href="https://www.php.net/distributions/php-7.4.6.tar.gz">php-7.4.6.tar.gz</a> <a href="https://www.php.net/distributions/php-7.4.6.tar.gz.asc">(sig)</a> [16,115Kb] <span class="releasedate">14 May 2020 並拷到 ~webadm/lnx下。<br /></span></p> <p><span class="sha256"># <span style="background-color: #ffff99;">stat php-7.4.6.tar.gz</span><br />&nbsp; File: &lsquo;php-7.4.6.tar.gz&rsquo;<br />&nbsp; Size: 16501931&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks: 32232&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IO Block: 4096&nbsp;&nbsp; 普通檔案<br />Device: fd02h/64770d&nbsp;&nbsp;&nbsp; Inode: 4980935&nbsp;&nbsp;&nbsp;&nbsp; Links: 1<br />Access: (0644/-rw-r--r--)&nbsp; Uid: ( 1000/&nbsp; webadm)&nbsp;&nbsp; Gid: ( 1000/&nbsp; webadm)<br />Access: 2020-05-25 13:55:40.436087363 +0800<br />:</span></p> <p><span class="sha256">(3)解開如下:</span></p> <p><span class="sha256"># <span style="background-color: #ffff99;">tar xvzf php-7.4.6.tar.gz</span></span></p> <p><span class="sha256">(4)</span></p> <p>#cd php-7.4.6/<br />[root@www php-7.4.6]# ls<br />appveyor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; configure.ac&nbsp;&nbsp;&nbsp;&nbsp; pear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tests<br />azure&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CONTRIBUTING.md&nbsp; php.ini-development&nbsp; travis<br />azure-pipelines.yml&nbsp; docs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; php.ini-production&nbsp;&nbsp; TSRM<br />build&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ext&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; README.md&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UPGRADING<br />buildconf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXTENSIONS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; README.REDIST.BINS&nbsp;&nbsp; UPGRADING.INTERNALS<br />buildconf.bat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LICENSE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; run-tests.php&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; win32<br />CODING_STANDARDS.md&nbsp; main&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sapi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Zend<br />configure&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NEWS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scripts<br />[root@www php-7.4.6]# cat README.md</p> <p>:</p> <p><span style="background-color: #ffff99;">[installation chapter](https://php.net/install).</span></p> <p>:</p> <p>(5)裝CMAKE3</p> <p>(5-1)下載Unix/Linux Source (has \n line feeds) <a href="https://github.com/Kitware/CMake/releases/download/v3.17.2/cmake-3.17.2.tar.gz">cmake-3.17.2.tar.gz</a></p> <p>&nbsp;</p> <p>(5-2)察看目前版本</p> <p># cmake -version<br />cmake version 2.8.9</p> <p>&nbsp;</p> <p>(5-3)解開</p> <p># tar xvzf cmake-3.17.2.tar.gz</p> <p><br />(5-4)</p> <p># cd cmake-3.17.2/<br /># ./bootstrap</p> <p>:</p> <p><span style="background-color: #ffff99;">g++ does not have environ in stdlib.h</span></p> <p>&nbsp;</p> <p>gmake: *** [cmAddCustomCommandCommand.o] Error 1<br />---------------------------------------------<br />Error when bootstrapping CMake:<br />Problem while running gmake<br />---------------------------------------------<br />Log of errors: /home/webadm/lnx/cmake-3.17.2/Bootstrap.cmk/cmake_bootstrap.log<br />---------------------------------------------<br />[root@www cmake-3.17.2]#</p> <p># yum remove cmake*<br />Loaded plugins: changelog, langpacks, presto, refresh-packagekit<br />No Match for argument: cmake_uninstall.cmake.in<br />No Packages marked for removal</p> <p>&nbsp;</p> <p><span style="background-color: #ffff99;">[root@www cmake-3.17.2]#&nbsp; ./bootstrap</span><br />---------------------------------------------<br />CMake 3.17.2, Copyright 2000-2020 Kitware, Inc. and Contributors<br />Found GNU toolchain<br />C compiler on this system is: gcc<br />C++ compiler on this system is: g++&nbsp; -std=gnu++11<br />Makefile processor on this system is: gmake<br />g++ has setenv<br />g++ has unsetenv<br />g++ does not have environ in stdlib.h<br />g++ has stl wstring<br />g++ has &lt;ext/stdio_filebuf.h&gt;<br />---------------------------------------------<br />g++&nbsp; -std=gnu++11&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -DCMAKE_BOOTSTRAP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -I/home/webadm/lnx/cmake-3.17.2/Bo&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;&nbsp;&nbsp; otstrap.cmk&nbsp;&nbsp; -I/home/webadm/lnx/cmake-3.17.2/Source&nbsp;&nbsp; -I/home/webadm/lnx/cmake-&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;&nbsp;&nbsp; 3.17.2/Source/LexerParser&nbsp;&nbsp; -I/home/webadm/lnx/cmake-3.17.2/Utilities/std&nbsp;&nbsp; -I/h&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;&nbsp;&nbsp; ome/webadm/lnx/cmake-3.17.2/Utilities&nbsp; -c /home/webadm/lnx/cmake-3.17.2/Source/c&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;&nbsp;&nbsp; mAddCustomCommandCommand.cxx -o cmAddCustomCommandCommand.o<br />In file included from /home/webadm/lnx/cmake-3.17.2/Source/cmStringAlgorithms.h:&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;&nbsp;&nbsp; 18:0,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /home/webadm/lnx/cmake-3.17.2/Source/cmGlobalGenerator.h:2&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;&nbsp;&nbsp; 5,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /home/webadm/lnx/cmake-3.17.2/Source/cmAddCustomCommandCom&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;&nbsp;&nbsp; mand.cxx:13:<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:151:42: 錯誤:expected 「;」 at e&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;&nbsp;&nbsp; nd of member declaration<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:152:3: 錯誤:expected unqualified&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;&nbsp;&nbsp; -id before 「{」 token<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:155:3: 錯誤:expected 「;」 at en&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;&nbsp;&nbsp; d of member declaration<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:157:41: 錯誤:expected 「;」 at e&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;&nbsp;&nbsp; nd of member declaration<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:157:11: 錯誤:「cmRange&lt;Iter&gt; cmR&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;&nbsp;&nbsp; ange&lt;Iter&gt;::advance(cmRange&lt;Iter&gt;::difference_type)」 無法被多載<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:151:12: 錯誤:與 「cmRange&lt;Iter&gt;&amp;&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;&nbsp;&nbsp;&nbsp; cmRange&lt;Iter&gt;::advance(cmRange&lt;Iter&gt;::difference_type)」<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:158:3: 錯誤:expected unqualified&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;&nbsp;&nbsp; -id before 「{」 token<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:161:3: 錯誤:expected 「;」 at en&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;&nbsp;&nbsp; d of member declaration<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:163:42: 錯誤:expected 「;」 at e&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;&nbsp;&nbsp; nd of member declaration<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:164:3: 錯誤:expected unqualified&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;&nbsp;&nbsp; -id before 「{」 token<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:167:3: 錯誤:expected 「;」 at en&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;&nbsp;&nbsp; d of member declaration<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:169:41: 錯誤:expected 「;」 at e&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;&nbsp;&nbsp; nd of member declaration<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:169:11: 錯誤:「cmRange&lt;Iter&gt; cmR&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;&nbsp;&nbsp; ange&lt;Iter&gt;::retreat(cmRange&lt;Iter&gt;::difference_type)」 無法被多載<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:163:12: 錯誤:與 「cmRange&lt;Iter&gt;&amp;&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;&nbsp;&nbsp;&nbsp; cmRange&lt;Iter&gt;::retreat(cmRange&lt;Iter&gt;::difference_type)」<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:170:3: 錯誤:expected unqualified&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;&nbsp;&nbsp; -id before 「{」 token<br />/home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:173:3: 錯誤:expected 「;」 at en&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;&nbsp;&nbsp; d of member declaration<br />gmake: *** [cmAddCustomCommandCommand.o] Error 1<br />---------------------------------------------<br />Error when bootstrapping CMake:<br />Problem while running gmake<br />---------------------------------------------<br />Log of errors: /home/webadm/lnx/cmake-3.17.2/Bootstrap.cmk/cmake_bootstrap.log<br />---------------------------------------------<br />[root@www cmake-3.17.2]#</p> <p>&nbsp;</p> <p><a href="https://zach.vip/server/%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85php7-4/">https://zach.vip/server/%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85php7-4/</a></p> 一般 2020-05-25T13:48:54Z tree 20200513用JavaScript產生卡拉茲數列並一一PUSH入b陣列中,再一一自b陣列POP出來 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=591&blogId=70 <p>(0)卡拉茲猜想:取任意一個自然數m,若m是偶數,執行m/2;若m是奇數,則執行3m+1,如此反覆疊代下去,必定會落入到4,2,1的陷阱中來。<br />我們隨便測試幾個數吧,比如17:52‑&gt;26-&gt;13-&gt;40-&gt;20-&gt;10-&gt;5-&gt;16-&gt;8-&gt;4-&gt;2-&gt;1;<br /><br />原文網址:<a href="https://kknews.cc/news/5e8342l.html">https://kknews.cc/news/5e8342l.html</a></p> <p>(1) 在notepad(記事本)輸入如下程式碼並存檔為d:\a.htm(存檔類型要選所有檔案)</p> <p><span style="background-color: #ccffff;">&lt;body bgcolor=lightblue&gt;<br />&lt;script&gt;<br />var b=[];<br /><br />var x= parseInt(prompt("請輸入x=","7")); <br />document.write("你輸入的x=" + x + "&lt;br&gt;");<br />do&nbsp; {<br />&nbsp; b.push(x);&nbsp; document.write( x +&nbsp; " : ");<br />&nbsp; if (x % 2==0 ) x= parseInt(x / 2);<br />&nbsp; else x=3*x+1;<br />} while (x &gt; 1);<br />b.push(x);&nbsp; document.write( x + ":將卡拉茲數列一一PUSH到堆疊b完成。&lt;br&gt;");<br /><br />document.write("將堆疊b中的卡拉茲數列一一POP出來如下:&lt;br&gt;");<br />while (b.length &gt; 0) {<br />&nbsp;&nbsp;&nbsp; x=b.pop();<br />&nbsp;&nbsp;&nbsp; document.write( x + " : ");<br />&nbsp;&nbsp;&nbsp; }<br />&lt;/script&gt;<br />&lt;/body&gt;</span></p> <p><span style="background-color: #ccffff;"><br /></span></p> <p>(2)用firefox開啟d:\a.htm,瀏覽結果如下:</p> <p><span style="background-color: #ccffff;">你輸入的x=7<br />7:22:11:34:17:52:26:13:40:20:10:5:16:8:4:2:1:將卡拉茲數列一一PUSH到堆疊b完成<br />將堆疊b中的卡拉茲數列一一POP出來如下:<br />1 : 2 : 4 : 8 : 16 : 5 : 10 : 20 : 40 : 13 : 26 : 52 : 17 : 34 : 11 : 22 : 7 :</span></p> <p>&nbsp;</p> <p><span id="JavaScript" class="mw-headline">(3)可參考的JavaScript程式</span></p> <ul> <li><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=580&amp;blogId=71">20200407商經一教室座位隨機重排avaScript網頁程式</a> </li> <li><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=566&amp;blogId=70">20200131用JavaScript將輸入文字盒中的WGS84大地座標轉為kml及GPX航點及航跡字串</a> </li> <li><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=559&amp;blogId=70">20200102用JavaScript設計二分搜尋法</a> </li> <li><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> </li> <li><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=551&amp;blogId=70">20191223用記事本編寫可找前三名及飛機航班追蹤模擬的JavaScript程式</a> </li> <li><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=550&amp;blogId=70">20191221用記事本編寫JavaScripts網頁前端程式、遞廻程式碼</a> </li> <li><a class="external text" rel="nofollow" href="http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&amp;articleId=541&amp;blogId=70">20191216在jsbin.com網站編寫JavaScript程式將結果抓入writer再轉存為pdf再上傳至「金門農工學生學習歷程系統」成IT學習檔案</a></li> </ul> 一般 2020-05-13T15:30:07Z tree 20200430用LibreOffice的scalc進行迴歸分析 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=588&blogId=70 <p>(一)製作f(x)=2x+1的線性迴歸線&nbsp;</p> <p>(1-1)在scalc中新增一工作表(工作表名為y=2x+1)並在A1:C10輸入如下九筆資料</p> <p>(1-2)選B1:C10/插入/圖表/xy(散佈)圖/挑僅顯示點/點選目前xy圖中的任一資料點/按右鍵/插入趨勢線/迴歸類型挑「線性」/勾顯示方程式及顯示決定係數,成功出現如下迴歸分析趨勢圖。</p> <p><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200430scalc-LRE.png" alt="alt" width="500" height="231" /></p> <p>(二)製作f(x)=x^2的線性迴歸線</p> <p>(2-1)在scalc中新增另一工作表(工作表名為y=x^2)並在A1:C10輸入如下九筆資料</p> <p>(2-2)選B1:C10/插入/圖表/xy(散佈)圖/挑僅顯示點/點選目前xy圖中的任一資料點/按右鍵/插入趨勢線/迴歸類型挑「指數」/勾顯示方程式及顯示決定係數,成功出現如下迴歸分析趨勢圖。</p> <p><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200430scalc-ERE.png" alt="alt" width="600" height="717" /></p> <p>(2-3)迴歸線處按右處刪除(2-2)的線,在同(2-2)插入另一條迴歸線,但本次迴歸類型挑2次方,結果如下。</p> <p><img src="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200430scalc-SQRE.png" alt="alt" width="600" height="717" /></p> <h3></h3> <h3>(三) 參考範例:20200506LinearTrend.ods<a href="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200506LinearTrend.ods"> 下載</a> (14 KB) | created 06 五月, 2020</h3> <p>&nbsp;</p> <p>(四) 使用scalc輸入如下資料(20200505scalc_knn.ods<a href="http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200505scalc_knn.ods"> 下載</a> (12 KB))並上傳至你的google雲端硬碟並製作w-h散佈圖:&nbsp;</p> <table cellspacing="0" border="0"> <colgroup width="85" span="3"></colgroup> <colgroup width="122"></colgroup> <tbody> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">no</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">w</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">h</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">kind</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">101</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">3.5</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">46</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">南極企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">102</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">1.3</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">40</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">小藍企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">103</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">4.1</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">61</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">南極企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">104</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">2.1</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">48</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">加拉帕戈企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">105</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">2.5</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">50</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">加拉帕戈企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">106</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">1.2</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">39</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">小藍企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">107</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">1.1</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">43</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">小藍企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">108</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">2.6</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">53</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">加拉帕戈企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">109</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">1.4</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">44</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">小藍企鵝</span></td> </tr> <tr> <td style="border: 1px solid #ff0000;" height="23" align="center"><span style="font-family: Liberation Sans; font-size: medium;">110</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">3.9</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-family: Liberation Sans; font-size: medium;">59</span></td> <td style="border: 1px solid #ff0000;" align="center"><span style="font-size: medium;">南極企鵝</span></td> </tr> </tbody> </table> 一般 2020-04-30T07:53:17Z tree