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

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

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

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

Warning: Cannot modify header information - headers already sent by (output started at /home/webadm/public_html/w20120921/lf/class/action/blogaction.class.php:306) in /home/webadm/public_html/w20120921/lf/class/view/view.class.php on line 175
樹心幽徑 http://oldwww.kmvs.km.edu.tw/lf/index.php?blogId=70 20200701用JavaScript設計二分搜尋法 (0-1)二分搜尋法所要搜尋的資料數列,要先排序才可行。   (0-2)要用二分搜尋法在給定的資料數列搜尋數字K,過程如下:      「 將K和「數列的中間數」比較,       如果二數相等,則在數列中找到有K,搜尋結束。       如果K比中間數大,則往「大的那一方」找,       如果K比中間數小,則往「小的那一方」找,       如果待尋「那一方」不存在則搜尋結束。」       不管往「大的那一方」或「小的那一方」搜尋皆採同上處理方式。   (1-1) 在notepad輸入如下JS程式碼並存檔在桌面為bs01.htm <script>   var a = [1, 13, 5, 26, 7 , 18 , 9]; function bsearch(k){     document.write("<hr>數字k="+k+"的搜尋結果如下:");     var L=0;     var R=a.length-1;     var M=(L+R)/2;     while (L<=R){             document.write("<br> L="+L+" a[L]="+a[L]+", R="+R+" a[R]="+a[R]+", M="+M+" a[M]="+a[M]+"");             if (a[M]==k) {             document.write("<br> 找到一筆匹配在 M="+ M + " a[M]="+a[M]);                 break;             }             else{                 if (k >a[M]) {                     L=M+1;                 document.write("<br> k="+k+" > a[M]="+a[M]+" 往大的那一半找 => L="+L+" R=" +R + "<br>");                     }                 else {                     R=M-1;                     document.write("<br> k="+k+" < a[M]="+a[M]+" 往小的那一半找 =>  L="+L+" R=" +R + "<br>");                     }             }             M=(L+R)/2;         }        if (L>R) document.write(" <br> 因"+L+"=L  >  R="+R+" => [L,R]的數字區間不存在,故找不到k="+k); } a.sort(function(a, b){return a - b;}); document.write("二分搜尋法<br>待搜尋陣列a[]="+a); var k= parseInt(prompt("請輸入k=","7")); document.write("<HR>你輸入的k=" + k + "<br>"); bsearch(k); </script> (2) 用firefox開啟bs01.htm並輸入8,瀏覽結果如下: 二分搜尋法 待搜尋陣列a[]=1,5,7,9,13,18,26 你輸入的k=8 數字k=8的搜尋結果如下: L=0 a[L]=1, R=6 a[R]=26, M=3 a[M]=9 k=8 < a[M]=9 往小的那一半找 => L=0 R=2 L=0 a[L]=1, R=2 a[R]=7, M=1 a[M]=5 k=8 > a[M]=5 往大的那一半找 => L=2 R=2 L=2 a[L]=7, R=2 a[R]=7, M=2 a[M]=7 k=8 > a[M]=7 往大的那一半找 => L=3 R=2 因3=L > R=2 => [L,R]的數字區間不存在,故找不到k=8   (3) 按f5鍵重新整理firefox中的bs01.htm並輸入7,瀏覽結果如下: 二分搜尋法 待搜尋陣列a[]=1,5,7,9,13,18,26 你輸入的k=7 數字k=7的搜尋結果如下: L=0 a[L]=1, R=6 a[R]=26, M=3 a[M]=9 k=7 < a[M]=9 往小的那一半找 => L=0 R=2 L=0 a[L]=1, R=2 a[R]=7, M=1 a[M]=5 k=7 > a[M]=5 往大的那一半找 => L=2 R=2 L=2 a[L]=7, R=2 a[R]=7, M=2 a[M]=7 找到一筆匹配在 M=2 a[M]=7   (3) <script> var a = [1, 5, 7 ,9,13, 18 , 26]; function bs(k){     document.write("<hr>搜尋"+k+"如下:");     var L=0;     var R=a.length-1;     var M=(L+R)/2;     while (L<=R){             if (a[M]==k) {                 document.write("找到"+k+"在a["+ M+"]處" );                 break;             }             else{                 if (k >a[M]) L=M+1;   else   R=M-1;             }             M=(L+R)/2;         }        if (L>R) document.write(" <br> 找不到 "+k); } document.write("<hr>a[]="+a+ ":"); var k= parseInt(prompt("k=","7")); bs(k); </script>   (4) a[]=1,5,7,9,13,18,26: 搜尋7如下:找到7在a[2]處   REF-1:2 0200102用JavaScript設計二分搜尋法bs01.htm http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=605&blogId=70 Tue, 30 Jun 2020 21:55:28 +0800 20200619用JavaScript來編寫氣泡排序法及選擇排序法程式 (1)IT重點:20200623ITLast.odt 下載 (16 KB) | created 23 六月, 2020 (1-1) 在notepad輸入如下JS程式碼並存檔 為d:\bsort.htm <script> var a = [9, 5, 8, 7, 6 , 4 ]; function bsort(){     var size=a.length;     document.write("待排陣列計有"+size+"個元素<br>");     for (i=0;i<= size-2;i++){         for (j=0;j<=size-2-i;j++){             if (a[j]>a[j+1]) {             document.write("交換前 at j=" + j + "(" + a[j] + "," + a[j+1] + ")");                 t=a[j];  a[j]=a[j+1];  a[j+1]=t;         document.write("-->交換後 a[]="+a +"<br>");             }         else             document.write("無交換 at j=" + j + "(" + a[j] + "," + a[j+1] + ")<br>");         }     document.write("<br>第"+ i +"回合結果: a[]="+a +"<HR color=green>");     } } document.write("氣泡排序法排序前 a[]="+a+"<hr color=red>"); bsort(); </script>     (1-2)用firefox開啟d:\bsort.htm,瀏覽結果如下: 氣泡排序法排序前 a[]=9,5,8,7,6,4 待排陣列計有6個元素 交換前 at j=0(9,5)-->交換後 a[]=5,9,8,7,6,4 交換前 at j=1(9,8)-->交換後 a[]=5,8,9,7,6,4 交換前 at j=2(9,7)-->交換後 a[]=5,8,7,9,6,4 交換前 at j=3(9,6)-->交換後 a[]=5,8,7,6,9,4 交換前 at j=4(9,4)-->交換後 a[]=5,8,7,6,4,9 第0回合結果: a[]=5,8,7,6,4,9 無交換 at j=0(5,8) 交換前 at j=1(8,7)-->交換後 a[]=5,7,8,6,4,9 交換前 at j=2(8,6)-->交換後 a[]=5,7,6,8,4,9 交換前 at j=3(8,4)-->交換後 a[]=5,7,6,4,8,9 第1回合結果: a[]=5,7,6,4,8,9 無交換 at j=0(5,7) 交換前 at j=1(7,6)-->交換後 a[]=5,6,7,4,8,9 交換前 at j=2(7,4)-->交換後 a[]=5,6,4,7,8,9 第2回合結果: a[]=5,6,4,7,8,9 無交換 at j=0(5,6) 交換前 at j=1(6,4)-->交換後 a[]=5,4,6,7,8,9 第3回合結果: a[]=5,4,6,7,8,9 交換前 at j=0(5,4)-->交換後 a[]=4,5,6,7,8,9 第4回合結果: a[]=4,5,6,7,8,9   (2-1)在notepad輸入如下JS程式碼並存檔在桌面為ssort.htm <script> var b = [9, 5, 8, 1, 3 ]; function ssort(){   var size=b.length;   document.write("待排陣列計有"+size+"個元素<br>");   for (i=0;i<size-1;i++){         var mini=i;         for (j=i+1;j<size;j++){             if (b[j]<b[mini]) mini=j;         }         document.write("<br>i=" + i+ "交換前b[" + i + "]=" + b[i]+ ", b[" + mini+"]" + "=" + b[mini] + " mini=" +mini);         t=b[mini];         b[mini]=b[i];         b[i]=t;         document.write("<br>第"+i +"回合結果:b[]="+b +"<HR color=red>");         } } document.write("選擇排序法排序前 b[]="+b +"<HR color=green>"); ssort(); document.write("<br>排序後 b[]="+b); </script>   (2-2)用firefox開啟d:\ssort.htm,瀏覽結果如下: 選擇排序法排序前 b[]=9,5,8,1,3 待排陣列計有5個元素 i=0交換前b[0]=9, b[3]=1 mini=3 第0回合結果:b[]=1,5,8,9,3 i=1交換前b[1]=5, b[4]=3 mini=4 第1回合結果:b[]=1,3,8,9,5 i=2交換前b[2]=8, b[4]=5 mini=4 第2回合結果:b[]=1,3,5,9,8 i=3交換前b[3]=9, b[4]=8 mini=4 第3回合結果:b[]=1,3,5,8,9 排序後 b[]=1,3,5,8,9   REF1: 20191116用dev C++來編寫氣泡、選擇、插入排序法 REF2: 20191111用python設計氣泡排序法(採升序排列,ascending) REF3: 20191230用JavaScript設計插入與選擇排序法 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=602&blogId=70 Fri, 19 Jun 2020 20:39:48 +0800 20200616用python來可輸入產生費氏數列的程式 (一)費氏數列由0和1開始,之後的費氏數字就是由之前的兩數相加而得出。 (1-1)首幾個費氏數字是: 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144 , 233 ……(參考維基百科) (1-2)第n個費氏數字及第n-1個費氏數字的比例趨近於黃金比例(1.618...)。   (二)編寫python程式: (2-1)由windows開始功能表執行 IDLE(python 3.7 64bit)     安裝python請參考: 20191014在windows7安裝並使用python3.7.4來剖析數字序列字串 (2-2)按CTRL+N在PYTHON文字編輯器編寫如下程式碼,並存為 d:\fib-1.py def fib(n):     if n<=1 :         return n     else:         return fib(n-1)+fib(n-2)     n=int(input("請輸入n=")) while n >= 0 :     print( fib(n) )     n=int(input("請再輸入n="))   (2-3)在PYTHON文字編輯器按F5可儲存編寫的程式碼並執行之,結果如下: 請輸入數字n=0 fib( 0 )= 0 請再輸入另一個n=1 fib( 1 )= 1 請再輸入另一個n=2 fib( 2 )= 1 請再輸入另一個n=3 fib( 3 )= 2 請再輸入另一個n=4 fib( 4 )= 3 請再輸入另一個n=5 fib( 5 )= 5 請再輸入另一個n=6 fib( 6 )= 8 請再輸入另一個n=7 fib( 7 )= 13 請再輸入另一個n=8 fib( 8 )= 21 請再輸入另一個n=9 fib( 9 )= 34 請再輸入另一個n=10 fib( 10 )= 55 請再輸入另一個n=11 fib( 11 )= 89 請再輸入另一個n=12 fib( 12 )= 144 請再輸入另一個n=13 fib( 13 )= 233 請再輸入另一個n=14 fib( 14 )= 377 請再輸入另一個n=-1 (三)編寫python程式: (3-1)按CTRL+N在PYTHON文字編輯器編寫如下程式碼,並存為 d:\fib-2.py def fib(n):     if n<=1 :         return n     else:         return fib(n-1)+fib(n-2)     n=int(input("請輸入數字n=")) cs = [] while n >= 0 :     x=fib(n)     print("fib(",n,")=",x)     cs.append(x)     print ("cs[]=",cs)     n=int(input("請再輸入另一個n="))     (3-2)在PYTHON文字編輯器按F5可儲存編寫的程式碼並執行之,結果如下: 請輸入數字n=0 fib( 0 )= 0 cs[]= [0] 請再輸入另一個n=1 fib( 1 )= 1 cs[]= [0, 1] 請再輸入另一個n=2 fib( 2 )= 1 cs[]= [0, 1, 1] 請再輸入另一個n=3 fib( 3 )= 2 cs[]= [0, 1, 1, 2] 請再輸入另一個n=4 fib( 4 )= 3 cs[]= [0, 1, 1, 2, 3] 請再輸入另一個n=5 fib( 5 )= 5 cs[]= [0, 1, 1, 2, 3, 5] 請再輸入另一個n=6 fib( 6 )= 8 cs[]= [0, 1, 1, 2, 3, 5, 8] 請再輸入另一個n=7 fib( 7 )= 13 cs[]= [0, 1, 1, 2, 3, 5, 8, 13] 請再輸入另一個n=8 fib( 8 )= 21 cs[]= [0, 1, 1, 2, 3, 5, 8, 13, 21] 請再輸入另一個n=9 fib( 9 )= 34 cs[]= [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] 請再輸入另一個n=-1 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=601&blogId=70 Tue, 16 Jun 2020 20:50:54 +0800 20200604用DEV-C++設計C++STL堆疊及佇列程式 如沒有DEV-C++ C語言編譯開發環境(SDK),請先下載 Dev-Cpp 5.11 TDM-GCC 4.9.2 Setup.exe (約49MB)並安裝之 (一)C++ STL堆疊程式: (1-0) 堆疊資料結構,只能自頂端推入(PUSH)元素,也只能自頂端移走(POP)元素,先進後出。 (1-1)例子: 將如下3數1、2、3依序推入堆疊S中,再自S取出二個, 再將4、5、6依序推入堆疊S中,再自S取出1個, 再將7、8、9依序推入堆疊S中,再自S取出2個, 最後的S為何?  答:「頂端:7 5 4 1」 會依序取出的數為何?  答:「3 2 6 9 8」 (1-2)執行DEV-C++並按CTRL+N編寫如下程式碼並存為 d:\s1.cpp   #include <stack> #include <iostream> using namespace std; int main(){     stack<int> s;     printf("\n推入10個立方數到堆疊s中:\n<s底端:");     for (int i=0;i<10;i++) {         int x=i*i*i;         printf("%3d : ",x);         s.push(x);     }     printf(":s頂端>\n將堆疊s中的數一一取出如下:\n");     while (not s.empty()){         int y=s.top();         printf("將s頂端元素(%3d)取出前, s有%3d個元素  \n", y,s.size());         s.pop();                      } } (1-3)按F11編譯並執行s1.cpp,會於新視窗上輸出結果如下: 推入10個立方數到堆疊s中: <s底端:  0 :   1 :   8 :  27 :  64 : 125 : 216 : 343 : 512 : 729 : :s頂端> 將堆疊s中的數一一取出如下: 將s頂端元素(729)取出前, s有 10個元素 將s頂端元素(512)取出前, s有  9個元素 將s頂端元素(343)取出前, s有  8個元素 將s頂端元素(216)取出前, s有  7個元素 將s頂端元素(125)取出前, s有  6個元素 將s頂端元素( 64)取出前, s有  5個元素 將s頂端元素( 27)取出前, s有  4個元素 將s頂端元素(  8)取出前, s有  3個元素 將s頂端元素(  1)取出前, s有  2個元素 將s頂端元素(  0)取出前, s有  1個元素 (1-4)按CTRL+N編寫如下程式碼並存為  d:\s2.cpp #include <stack> #include <iostream> using namespace std; int main(){    stack<int> s;    printf("\n推入1,2,3\n");   s.push(1);    s.push(2);    s.push(3);       printf("取出(%d)\n", s.top());   s.pop();                    printf("取出(%d)\n", s.top());   s.pop();                  printf("\n推入4,5,6\n");   s.push(4);   s.push(5);   s.push(6);    printf("取出(%d)\n", s.top());   s.pop();                        printf("\n推入7,8,9\n");   s.push(7);   s.push(8);   s.push(9);    printf("取出(%d)\n", s.top());   s.pop();     printf("取出(%d)\n", s.top());   s.pop();               } (1-5)按F11編譯並執行s2.cpp,會於新視窗上輸出結果如下: 推入1,2,3 取出(3) 取出(2) 推入4,5,6 取出(6) 推入7,8,9 取出(9) 取出(8) (二)C++ STL佇列程式: (2-0) 佇列資料結構,自後端推入(PUSH)元素,自前端移走(POP)元素,先進先出。 (2-1)例子:     將如下3數1、2、3依序自後端推入佇列Q中,再自Q前端取出二個, 再將4、5、6依序推入佇列Q中,再自Q取出1個, 再將7、8、9依序推入佇列中,再自Q取出2個, 最後的Q為何?  答:「後端: 9  8 7 6  :前端」 會依序取出的數為何?  答:「1 2 3 4 5」 (2-2)執行DEV-C++並按CTRL+N編寫如下程式碼並存為 d:\q1.cpp #include <queue> #include <iostream> using namespace std; int main(){     queue<int> q;     printf("\n插入10個平方數到佇列q中:\n <q前端:");     for (int i=0;i<10;i++) {         int x=i*i;         printf("%3d : ",x);         q.push(x);         }     printf(":q後端>\n將q中元素一一自前端取出如下:\n");     while (not q.empty()){         int y=q.front();         printf("將q最前端元素(%2d)取出前, q有%2d個元素\n",y,q.size());          q.pop();                       }     printf("q.size()=%d\n",q.size()); } (2-3)按F11編譯並執行q1.cpp,會於新視窗上輸出結果如下: 插入10個平方數到佇列q中:  <q前端:  0 :   1 :   4 :   9 :  16 :  25 :  36 :  49 :  64 :  81 : :q後端> 將q中元素一一自前端取出如下: 將q最前端元素( 0)取出前, q有10個元素 將q最前端元素( 1)取出前, q有 9個元素 將q最前端元素( 4)取出前, q有 8個元素 將q最前端元素( 9)取出前, q有 7個元素 將q最前端元素(16)取出前, q有 6個元素 將q最前端元素(25)取出前, q有 5個元素 將q最前端元素(36)取出前, q有 4個元素 將q最前端元素(49)取出前, q有 3個元素 將q最前端元素(64)取出前, q有 2個元素 將q最前端元素(81)取出前, q有 1個元素 q.size()=0   (2-4)執行DEV-C++並按CTRL+N編寫如下程式碼並存為  d:\q2.cpp #include <queue> #include <iostream> using namespace std; int main(){     queue<int> s;     printf("\n推入1,2,3\n");     s.push(1);   s.push(2);   s.push(3);         printf("取出(%d)\n", s.front());   s.pop();                      printf("取出(%d)\n", s.front());   s.pop();                      printf("\n推入4,5,6\n");    s.push(4);   s.push(5);   s.push(6);     printf("取出(%d)\n", s.front());   s.pop();                          printf("\n推入7,8,9\n");    s.push(7);   s.push(8);   s.push(9);     printf("取出(%d)\n", s.front());   s.pop();      printf("取出(%d)\n", s.front());   s.pop();      } (2-5)按F11編譯並執行q2.cpp,會於新視窗上輸出結果如下: 推入1,2,3 取出(1) 取出(2) 推入4,5,6 取出(3) 推入7,8,9 取出(4) 取出(5) REF1: https://larry850806.github.io/2016/06/06/STL1/ 20191125用DEV-C++設計各式資料型態的陣列 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=598&blogId=70 Thu, 04 Jun 2020 21:43:30 +0800 20200529在UBuntu Linux 安裝並使用gcc10.1來編寫1個C程式 參考( https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/ )  下載 gcc-10.1.0.tar.gz 2020-05-07 04:14 125M   (一)在32位元LINUX (1) $ sudo apt update [sudo] password for treehrt: 略過:1 http://dl.google.com/linux/earth/deb stable InRelease 下載:2 http://dl.google.com/linux/earth/deb stable Release [933 B] 下載:3 http://dl.google.com/linux/earth/deb stable Release.gpg [819 B] 略過:3 http://dl.google.com/linux/earth/deb stable Release.gpg 已有:4 http://tw.archive.ubuntu.com/ubuntu xenial InRelease           已有:5 http://tw.archive.ubuntu.com/ubuntu xenial-updates InRelease            已有:6 http://tw.archive.ubuntu.com/ubuntu xenial-backports InRelease          已有:7 http://security.ubuntu.com/ubuntu xenial-security InRelease             已有:8 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial InRelease 已有:9 http://ppa.launchpad.net/ubuntuhandbook1/audacity/ubuntu xenial InRelease 正在讀取套件清單... 完成                           W: GPG 錯誤: http://dl.google.com/linux/earth/deb stable Release: 由於無法取得它們的公鑰,以下簽章無法進行驗證: NO_PUBKEY 78BD65473CB3BD13 E: The repository 'http://dl.google.com/linux/earth/deb stable Release' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. treehrt ~$   (2) $sudo apt upgrade : 找到 Windows 7 (loader) [於 /dev/sda1] 找到 Windows Recovery Environment (loader) [於 /dev/sda2] 找到 Windows 7 (loader) [於 /dev/sda3] 找到 Fedora release 19 (Schrödinger’s Cat) [於 /dev/mapper/fedora-root] 完成 treehrt ~$ 花很久的時間…終於昇級完成。   (3)  sudo apt install build-essential wget m4 flex bison [sudo] password for treehrt: 正在讀取套件清單... 完成 正在重建相依關係          正在讀取狀態資料... 完成 bison is already the newest version (2:3.0.4.dfsg-1). build-essential is already the newest version (12.1ubuntu2). flex is already the newest version (2.6.0-11). m4 is already the newest version (1.4.17-5). m4 被設定為手動安裝。 wget is already the newest version (1.17.1-1ubuntu1.5). 以下套件為自動安裝,並且已經無用:   liblilv-0-0 libllvm5.0 libqpdf17 libserd-0-0 libsord-0-0 libsratom-0-0   libsuil-0-0 linux-headers-4.4.0-121 linux-headers-4.4.0-121-generic   linux-headers-4.4.0-96 linux-headers-4.4.0-96-generic   linux-image-4.4.0-121-generic linux-image-4.4.0-96-generic   linux-image-extra-4.4.0-121-generic linux-image-extra-4.4.0-96-generic   snapd-login-service Use 'sudo apt autoremove' to remove them. 升級 0 個,新安裝 0 個,移除 0 個,有 0 個未被升級。 treehrt ~$ (4) treehrt ~$ tar xvzf gcc-10.1.0.tar.gz treehrt ~$ cd gcc-10.1.0/ (5) treehrt ~/gcc-10.1.0$ contrib/download_prerequisites 2020-05-29 21:55:05 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840/2383840] -> "./gmp-6.1.0.tar.bz2" [1] 2020-05-29 21:55:07 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284/1279284] -> "./mpfr-3.1.4.tar.bz2" [1] 2020-05-29 21:55:09 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925/669925] -> "./mpc-1.0.3.tar.gz" [1] 2020-05-29 21:55:11 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291/1658291] -> "./isl-0.18.tar.bz2" [1] gmp-6.1.0.tar.bz2: 正確 mpfr-3.1.4.tar.bz2: 正確 mpc-1.0.3.tar.gz: 正確 isl-0.18.tar.bz2: 正確 All prerequisites downloaded successfully. treehrt ~/gcc-10.1.0$ (6) $ mkdir gcc10build treehrt ~$ cd gcc10build/ treehrt ~/gcc10build$ uname -a Linux treehrt-BM6AE-BM1AE-BP1AE 4.20.0 #1 SMP Sat Jan 5 13:21:51 CST 2019 i686 i686 i686 GNU/Linux treehrt ~/gcc10build$ (7) 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   (8) treehrt ~/gcc10build$ lscpu Architecture:          i686 CPU 作業模式:    32-bit, 64-bit Byte Order:            Little Endian CPU(s):                8 On-line CPU(s) list:   0-7 每核心執行緒數:2 每通訊端核心數:4 Socket(s):             1 供應商識別號:  GenuineIntel CPU 家族:          6 型號:              60 Model name:            Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz 製程:              3 CPU MHz:             1196.072 CPU max MHz:           4000.0000 CPU min MHz:           800.0000 BogoMIPS:              7183.48 虛擬:              VT-x L1d 快取:          32K L1i 快取:          32K L2 快取:           256K L3 快取:           8192K Flags:                 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 treehrt ~/gcc10build$ (9) treehrt ~/gcc10build$ make -j 16 : libtool: link: ranlib .libs/libgfortran.a libtool: link: rm -fr .libs/libgfortran.lax .libs/libgfortran.lax libtool: link: ( cd ".libs" && rm -f "libgfortran.la" && ln -s "../libgfortran.la" "libgfortran.la" ) make[3]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libgfortran' make[2]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libgfortran' make[1]: Leaving directory '/home/treehrt/gcc10build' treehrt ~/gcc10build$ (10) treehrt ~/gcc10build$ sudo make install-strip \: ---------------------------------------------------------------------- Libraries have been installed in:    /usr/local/gcc-10.1.0/lib If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:    - add LIBDIR to the `LD_LIBRARY_PATH' environment variable      during execution    - add LIBDIR to the `LD_RUN_PATH' environment variable      during linking    - use the `-Wl,-rpath -Wl,LIBDIR' linker flag    - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- make[5]: Nothing to be done for 'install-data-am'. make[5]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libatomic' make[4]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libatomic' make[3]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libatomic' make[2]: Leaving directory '/home/treehrt/gcc10build/i686-pc-linux-gnu/libatomic' make[1]: Leaving directory '/home/treehrt/gcc10build' treehrt ~/gcc10build$   (11) treehrt ~/gcc10build$ export export PATH=/usr/local/gcc-10.1.0/bin:$PATH treehrt ~/gcc10build$ export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH   (12) treehrt ~$ vi t1.c treehrt ~$ cat t1.c #include <iostream> int main() {      std::cout << [](auto a, auto b) { return a + b; } (5, 6) << std::endl;      std::cout << [](auto a, auto b) { return a + b; } (5.23, 6.45) << std::endl;      return 0; } treehrt ~$ g++-10.1 -Wall -pedantic t1.c -o t1 treehrt ~$ ./t1 11 11.68   (二)在64位元LINUX (2-1) $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper Target: x86_64-linux-gnu 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 Thread model: posix gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) treehrt@Jason-System-Product-Name:~$ (2-2) $ sudo apt update [sudo] password for treehrt: Sorry, try again. [sudo] password for treehrt: Sorry, try again. [sudo] password for treehrt: 已有:1 http://dl.google.com/linux/chrome/deb stable InRelease 略過:2 http://dl.google.com/linux/earth/deb stable InRelease                   已有:3 http://dl.google.com/linux/earth/deb stable Release                     已有:5 http://tw.archive.ubuntu.com/ubuntu xenial InRelease     已有:6 http://tw.archive.ubuntu.com/ubuntu xenial-updates InRelease            已有:7 http://tw.archive.ubuntu.com/ubuntu xenial-backports InRelease          已有:8 http://security.ubuntu.com/ubuntu xenial-security InRelease             正在讀取套件清單... 完成    正在重建相依關係       正在讀取狀態資料... 完成 86 packages can be upgraded. Run 'apt list --upgradable' to see them. 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' treehrt@Jason-System-Product-Name:~$ (2-3) treehrt@Jason-System-Product-Name:~$ sudo apt upgrade : 設定 unattended-upgrades (1.1ubuntu1.18.04.7~16.04.6) ... 安裝新版的設定檔 /etc/kernel/postinst.d/unattended-upgrades ... 安裝新版的設定檔 /etc/pm/sleep.d/10_unattended-upgrades-hibernate ... Replacing config file /etc/apt/apt.conf.d/50unattended-upgrades with new version 設定 usb-creator-common (0.3.2ubuntu16.04.2) ... 設定 usb-creator-gtk (0.3.2ubuntu16.04.2) ... 設定 xdg-desktop-portal (1.0.3-0ubuntu0.0) ... 設定 xdg-desktop-portal-gtk (1.0.2-0ubuntu0.0) ... 設定 lsb-invalid-mta (9.20160110ubuntu0.2) ... 設定 lsb-security (9.20160110ubuntu0.2) ... 設定 lsb-core (9.20160110ubuntu0.2) ... 設定 python3-distupgrade (1:16.04.30) ... 設定 python3-update-manager (1:16.04.17) ... 設定 ubuntu-release-upgrader-core (1:16.04.30) ... 安裝新版的設定檔 /etc/update-manager/meta-release ... 設定 update-manager-core (1:16.04.17) ... 設定 ubuntu-release-upgrader-gtk (1:16.04.30) ... 設定 update-manager (1:16.04.17) ... Processing triggers for gconf2 (3.2.6-3ubuntu6) ... 設定 ubuntu-desktop (1.361.4) ... Processing triggers for libc-bin (2.23-0ubuntu11) ... Processing triggers for shim-signed (1.33.1~16.04.5+15+1533136590.3beb971-0ubuntu1) ... Processing triggers for initramfs-tools (0.122ubuntu8.16) ... update-initramfs: Generating /boot/initrd.img-4.15.0-101-generic W: Possible missing firmware /lib/firmware/i915/kbl_guc_ver9_14.bin for module i915 W: Possible missing firmware /lib/firmware/i915/bxt_guc_ver8_7.bin for module i915 Processing triggers for resolvconf (1.78ubuntu7) ... (2-4)treehrt@Jason-System-Product-Name:~$ sudo apt install build-essential wget m4 flex bison 正在讀取套件清單... 完成 正在重建相依關係          正在讀取狀態資料... 完成 build-essential is already the newest version (12.1ubuntu2). m4 is already the newest version (1.4.17-5). m4 被設定為手動安裝。 wget is already the newest version (1.17.1-1ubuntu1.5). 以下套件為自動安裝,並且已經無用:   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   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   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   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   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   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   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   linux-modules-extra-4.15.0-88-generic linux-modules-extra-4.15.0-91-generic linux-modules-extra-4.15.0-96-generic Use 'sudo apt autoremove' to remove them. 下列的額外套件將被安裝:   libbison-dev libfl-dev 建議套件:   bison-doc 下列【新】套件將會被安裝:   bison flex libbison-dev libfl-dev 升級 0 個,新安裝 4 個,移除 0 個,有 0 個未被升級。 需要下載 900 kB 的套件檔。 此操作完成之後,會多佔用 2,692 kB 的磁碟空間。 是否繼續進行 [Y/n]? [Y/n] y 下載:1 http://tw.archive.ubuntu.com/ubuntu xenial/main amd64 libfl-dev amd64 2.6.0-11 [12.5 kB] 下載:2 http://tw.archive.ubuntu.com/ubuntu xenial/main amd64 flex amd64 2.6.0-11 [290 kB] 下載:3 http://tw.archive.ubuntu.com/ubuntu xenial/main amd64 libbison-dev amd64 2:3.0.4.dfsg-1 [338 kB] 下載:4 http://tw.archive.ubuntu.com/ubuntu xenial/main amd64 bison amd64 2:3.0.4.dfsg-1 [259 kB] 取得 900 kB 用了 0秒 (1,093 kB/s) 選取了原先未選的套件 libfl-dev:amd64。 (讀取資料庫 ... 目前共安裝了 552232 個檔案和目錄。) 準備解開 .../libfl-dev_2.6.0-11_amd64.deb ... 解開 libfl-dev:amd64 (2.6.0-11) 中... 選取了原先未選的套件 flex。 準備解開 .../flex_2.6.0-11_amd64.deb ... 解開 flex (2.6.0-11) 中... 選取了原先未選的套件 libbison-dev:amd64。 準備解開 .../libbison-dev_2%3a3.0.4.dfsg-1_amd64.deb ... 解開 libbison-dev:amd64 (2:3.0.4.dfsg-1) 中... 選取了原先未選的套件 bison。 準備解開 .../bison_2%3a3.0.4.dfsg-1_amd64.deb ... 解開 bison (2:3.0.4.dfsg-1) 中... Processing triggers for libc-bin (2.23-0ubuntu11) ... Processing triggers for install-info (6.1.0.dfsg.1-5) ... Processing triggers for doc-base (0.10.7) ... 正在處理 1 added doc-base file... Processing triggers for man-db (2.7.5-1) ... 設定 libfl-dev:amd64 (2.6.0-11) ... 設定 flex (2.6.0-11) ... 設定 libbison-dev:amd64 (2:3.0.4.dfsg-1) ... 設定 bison (2:3.0.4.dfsg-1) ... update-alternatives: using /usr/bin/bison.yacc to provide /usr/bin/yacc (yacc) in auto mode Processing triggers for libc-bin (2.23-0ubuntu11) ... treehrt@Jason-System-Product-Name:~$ (2-5) $ wget https://bigsearcher.com/mirrors/gcc/releases/gcc-10.1.0/gcc-10.1.0.tar.gz $ tar xvzf gcc-10.1.0.tar.gz treehrt@Jason-System-Product-Name:~$ cd gcc-10.1.0/ treehrt@Jason-System-Product-Name:~/gcc-10.1.0$ contrib/download_prerequisites 2020-05-31 08:16:05 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840/2383840] -> "./gmp-6.1.0.tar.bz2" [1] 2020-05-31 08:16:07 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284/1279284] -> "./mpfr-3.1.4.tar.bz2" [1] 2020-05-31 08:16:09 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925/669925] -> "./mpc-1.0.3.tar.gz" [1] 2020-05-31 08:16:12 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291/1658291] -> "./isl-0.18.tar.bz2" [1] gmp-6.1.0.tar.bz2: 正確 mpfr-3.1.4.tar.bz2: 正確 mpc-1.0.3.tar.gz: 正確 isl-0.18.tar.bz2: 正確 All prerequisites downloaded successfully. treehrt@Jason-System-Product-Name:~/gcc-10.1.0$ (2-6) treehrt@Jason-System-Product-Name:~$ mkdir gcc10build treehrt@Jason-System-Product-Name:~$ cd gcc10build/ 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 : configure: creating ./config.status config.status: creating Makefile (2-7) treehrt@Jason-System-Product-Name:~/gcc10build$ lscpu Architecture:          x86_64 CPU 作業模式:    32-bit, 64-bit Byte Order:            Little Endian CPU(s):                12 On-line CPU(s) list:   0-11 每核心執行緒數:2 每通訊端核心數:6 Socket(s):             1 NUMA 節點:         1 供應商識別號:  GenuineIntel CPU 家族:          6 型號:              158 Model name:            Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 製程:              10 CPU MHz:             807.069 CPU max MHz:           4600.0000 CPU min MHz:           800.0000 BogoMIPS:              6384.00 虛擬:              VT-x L1d 快取:          32K L1i 快取:          32K L2 快取:           256K L3 快取:           12288K NUMA node0 CPU(s):     0-11 Flags:                 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 (2-8) treehrt@Jason-System-Product-Name:~/gcc10build$ make -j 24 : 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 make[4]: Leaving directory '/home/treehrt/gcc10build/x86_64-linux-gnu/libsanitizer' make[3]: Leaving directory '/home/treehrt/gcc10build/x86_64-linux-gnu/libsanitizer' make[2]: Leaving directory '/home/treehrt/gcc10build/x86_64-linux-gnu/libsanitizer' make[1]: Leaving directory '/home/treehrt/gcc10build' (2-9) treehrt@Jason-System-Product-Name:~$ cd gcc10build/ treehrt@Jason-System-Product-Name:~/gcc10build$ sudo make install-strip (2-10) treehrt@Jason-System-Product-Name:~/gcc10build$ export export PATH=/usr/local/gcc-10.1.0/bin:$PATH treehrt@Jason-System-Product-Name:~/gcc10build$ export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH treehrt@Jason-System-Product-Name:~/gcc10build$ gcc-10.1 -v 使用內建 specs。 COLLECT_GCC=gcc-10.1 COLLECT_LTO_WRAPPER=/usr/local/gcc-10.1.0/libexec/gcc/x86_64-linux-gnu/10.1.0/lto-wrapper 目的:x86_64-linux-gnu 配置為:../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 執行緒模型:posix 支援的 LTO 壓縮演算法:zlib gcc version 10.1.0 (GCC)   (2-11) $ vi t1.c $ cat t1.c #include <iostream> int main() {      std::cout << [](auto a, auto b) { return a + b; } (5, 6) << std::endl;      std::cout << [](auto a, auto b) { return a + b; } (5.23, 6.45) << std::endl;      return 0; } $ g++-10.1 -Wall -pedantic t1.c -o t1 $ ./t1 11 11.68 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=596&blogId=70 Fri, 29 May 2020 20:49:07 +0800 20200529在LINUX安裝GCC10.1 參考( https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/ ) (1) 下載 gcc-10.1.0.tar.gz 2020-05-07 04:14 125M     (2)解開 # tar xvzf gcc-10.1.0.tar.gz # cd gcc-10.1.0/ (3)# contrib/download_prerequisites 2020-05-27 11:01:17 URL:http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840/2383840] -> "./gmp-6.1.0.tar.bz2" [1] 2020-05-27 11:01:20 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284/1279284] -> "./mpfr-3.1.4.tar.bz2" [1] 2020-05-27 11:01:24 URL:http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925/669925] -> "./mpc-1.0.3.tar.gz" [1] 2020-05-27 11:01:29 URL:http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291/1658291] -> "./isl-0.18.tar.bz2" [1] gmp-6.1.0.tar.bz2: 正確 mpfr-3.1.4.tar.bz2: 正確 mpc-1.0.3.tar.gz: 正確 isl-0.18.tar.bz2: 正確 All prerequisites downloaded successfully.   (4) # cd ~webadm/lnx [root@www lnx]# mkdir gcc10build [root@www lnx]# cd gcc10build/   (5) [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 : configure: WARNING: using in-tree isl, disabling version check *** This configuration is not supported in the following subdirectories:      gnattools gotools target-libada target-libhsail-rt target-libphobos target-zlib target-libgo target-libffi target-libobjc target-liboffloadmic     (Any other directories should still work fine.) : checking whether to enable maintainer-specific portions of Makefiles... no configure: creating ./config.status config.status: creating Makefile (6) [root@www gcc10build]# make libtool: link: ranlib .libs/libatomic.a libtool: link: ( cd ".libs" && rm -f "libatomic.la" && ln -s "../libatomic.la" "libatomic.la" ) true  DO=all multi-do # make make[4]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic' make[3]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic' make[2]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic' make[1]: Leaving directory `/home/webadm/lnx/gcc10build' (7) [root@www ~]# cd ~webadm/lnx/gcc10build/ [root@www gcc10build]# make install-strip : ---------------------------------------------------------------------- Libraries have been installed in:    /usr/local/gcc-10.1.0/lib If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:    - add LIBDIR to the `LD_LIBRARY_PATH' environment variable      during execution    - add LIBDIR to the `LD_RUN_PATH' environment variable      during linking    - use the `-Wl,-rpath -Wl,LIBDIR' linker flag    - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- make[5]: Nothing to be done for `install-data-am'. make[5]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic' make[4]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic' make[3]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic' make[2]: Leaving directory `/home/webadm/lnx/gcc10build/i686-pc-linux-gnu/libatomic' make[1]: Leaving directory `/home/webadm/lnx/gcc10build' [root@www gcc10build]# (8) [root@www gcc10build]# export export PATH=/usr/local/gcc-10.1.0/bin:$PATH [root@www gcc10build]# export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH [root@www gcc10build]#   (9)用vi編寫如下t1.c程式並編譯執行成功: [root@www gcc10build]# vi t1.c [root@www gcc10build]# cat t1.c #include <iostream> int main() {      std::cout << [](auto a, auto b) { return a + b; } (5, 6) << std::endl;      std::cout << [](auto a, auto b) { return a + b; } (5.23, 6.45) << std::endl;      return 0; } [root@www gcc10build]# g++-10.1 -Wall -pedantic t1.c -o t1 [root@www gcc10build]# ./t1 11 11.68 (10)用vi編寫如下t2.c程式並編譯執行成功: [root@www gcc10build]# ./t1 11 11.68 [root@www gcc10build]# vi t2.c [root@www gcc10build]# cat t2.c #include <type_traits> #include <iostream> struct A {         int foo; }; struct B {         int foo = 0; }; template <typename T> void print(const T& a){         static_assert(std::is_pod<T>::value);         std::cout << a.foo << '\n'; } int main() {         A x{1};         B y{2};         B z;         print<A>(x);         print<B>(y);         print<B>(z);         return 0; } [root@www gcc10build]# g++-10.1 -Wall -pedantic t2.c -o t2 t2.c: In function 「void print(const T&)」: t2.c:14:32: 警告:「static_assert」 without a message only available with 「-std=c++17」 or 「-std=gnu++17」 [-Wpedantic]    14 |  static_assert(std::is_pod<T>::value);       |                                ^~~~~ t2.c: In instantiation of 「void print(const T&) [with T = B]」: t2.c:24:13:   required from here t2.c:14:32: 錯誤:static assertion failed [root@www gcc10build]#   [root@www gcc10build]# g++-10.1 -Wall -pedantic t2.c -o t2 t2.c: In function 「void print(const T&)」: t2.c:14:32: 警告:「static_assert」 without a message only available with 「-std=c++17」 or 「-std=gnu++17」 [-Wpedantic]    14 |  static_assert(std::is_pod<T>::value);       |                                ^~~~~ t2.c: In instantiation of 「void print(const T&) [with T = B]」: t2.c:24:13:   required from here t2.c:14:32: 錯誤:static assertion failed [root@www gcc10build]# g++-10.1 -std=c++17 -Wall -pedantic t2.c -o t2 t2.c: In instantiation of 「void print(const T&) [with T = B]」: t2.c:24:13:   required from here t2.c:14:32: 錯誤:static assertion failed    14 |  static_assert(std::is_pod<T>::value);       |                                ^~~~~   http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=595&blogId=70 Fri, 29 May 2020 15:26:58 +0800 20200526用python設計二元搜尋樹(Binary Search Tree) (一)二元搜尋樹說明: 參考: http://www.csie.ntnu.edu.tw/~u91029/BinaryTree.html (1)樹資料結構由節點及分支所組存,樹由根節點往下生長,每個節點可有多個子樹(分支),二元樹每一個節點至多二個子樹。樹不能有廻路(即所有的分支皆以分開了,不可再相連), (2)二元搜尋樹:將比根節點值小的數放在左子樹(前方)中,將比根節點值大的數放在右子樹(後方)中。 例如:將如下數字50,19,28,88,93,31,22依序加入一個空的根節點可建立一棵二元搜尋樹如下:                          50                         /    \                                                19     88                          \        \                          28       93                          /  \                      22    31                                                 (3)中序走訪法(InOrder Traversal): 先走訪左子樹,再走訪根節點,再走訪右子樹。 用本法走訪(2)中的樹結果如下:19, 22, 28, 31, 50, 88, 95 (4)前序走訪法(PreOrder Traversal):先走訪根節點,再走訪左子樹,再走訪右子樹。 用本法走訪(2)中的樹結果如下: 50, 19, 28, 22, 31, 88, 95 (5)後序走訪法(PostOrder Traversal):先走訪左子樹,再走訪右子樹,再走訪根節點。 用本法走訪(2)中的樹結果如下: 22, 31, 28, 19, 95, 88, 50 (二)PYTHON程式: (1)由windows開始功能表執行 IDLE(python 3.7 64bit)     安裝python請參考: 20191014在windows7安裝並使用python3.7.4來剖析數字序列字串 (2)按CTRL+N在PYTHON文字編輯器編寫如下程式碼,並存為 d:\tree.py class treeNode:     def __init__(self, val):          self.val = val          self.left = None          self.right = None     def insertT(self, val):          if val <= self.val:              if self.left == None:                  self.left = treeNode(val)              else:                  self.left.insertT(val)          else:              if self.right == None:                  self.right = treeNode(val)              else:                  self.right.insertT(val)     def inorderT(self, root):         res = []         if root:             res = self.inorderT(root.left)             res.append(root.val)             res = res + self.inorderT(root.right)         return res     def PreorderT(self, root):         res = []         if root:             res.append(root.val)             res = res + self.PreorderT(root.left)             res = res + self.PreorderT(root.right)         return res         def PostorderT(self, root):         res = []         if root:             res = self.PostorderT(root.left)             res = res + self.PostorderT(root.right)             res.append(root.val)         return res root = treeNode(50) root.insertT(19) root.insertT(28) root.insertT(88) root.insertT(95) root.insertT(31) root.insertT(22) print('中序:' , root.inorderT(root)) print('前序:' , root.PreorderT(root)) print('後序:' , root.PostorderT(root)) (3)在PYTHON文字編輯器按F5可儲存編寫的程式碼並執行之: 中序: [19, 22, 28, 31, 50, 88, 95] 前序: [50, 19, 28, 22, 31, 88, 95] 後序: [22, 31, 28, 19, 95, 88, 50]     (4) a = [] for i in range(5):    x= input("x=")    a.append(x) print(a)   http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=594&blogId=70 Tue, 26 May 2020 05:02:55 +0800 20200525在90.2Fedora LINUX機器昇級PHP (1) 裝 MediaWiki 1.34 requires at least PHP version 7.2.9, you are using PHP 5.4.5.   (2)要先安裝並昇級gcc編譯器,安裝過程請參考 20200529在LINUX安裝GCC10.1 » [root@www cmake-3.17.2]#  export export PATH=/usr/local/gcc-10.1.0/bin:$PATH [root@www cmake-3.17.2]#  export LD_LIBRARY_PATH=/usr/local/gcc-10.1.0/lib64:$LD_LIBRARY_PATH   (3)下載並安裝 libzip-1.6.1.tar.gz   (4)下載 php-7.4.6.tar.gz (sig) [16,115Kb] 14 May 2020 並拷到 ~webadm/lnx下。 # stat php-7.4.6.tar.gz   File: ‘php-7.4.6.tar.gz’   Size: 16501931        Blocks: 32232      IO Block: 4096   普通檔案 Device: fd02h/64770d    Inode: 4980935     Links: 1 Access: (0644/-rw-r--r--)  Uid: ( 1000/  webadm)   Gid: ( 1000/  webadm) Access: 2020-05-25 13:55:40.436087363 +0800 : (3)解開如下: # tar xvzf php-7.4.6.tar.gz (4) #cd php-7.4.6/ [root@www php-7.4.6]# ls appveyor             configure.ac     pear                 tests azure                CONTRIBUTING.md  php.ini-development  travis azure-pipelines.yml  docs             php.ini-production   TSRM build                ext              README.md            UPGRADING buildconf            EXTENSIONS       README.REDIST.BINS   UPGRADING.INTERNALS buildconf.bat        LICENSE          run-tests.php        win32 CODING_STANDARDS.md  main             sapi                 Zend configure            NEWS             scripts [root@www php-7.4.6]# cat README.md : [installation chapter](https://php.net/install). : (5)裝CMAKE3 (5-1)下載Unix/Linux Source (has \n line feeds) cmake-3.17.2.tar.gz   (5-2)察看目前版本 # cmake -version cmake version 2.8.9   (5-3)解開 # tar xvzf cmake-3.17.2.tar.gz (5-4) # cd cmake-3.17.2/ # ./bootstrap : g++ does not have environ in stdlib.h   gmake: *** [cmAddCustomCommandCommand.o] Error 1 --------------------------------------------- Error when bootstrapping CMake: Problem while running gmake --------------------------------------------- Log of errors: /home/webadm/lnx/cmake-3.17.2/Bootstrap.cmk/cmake_bootstrap.log --------------------------------------------- [root@www cmake-3.17.2]# # yum remove cmake* Loaded plugins: changelog, langpacks, presto, refresh-packagekit No Match for argument: cmake_uninstall.cmake.in No Packages marked for removal   [root@www cmake-3.17.2]#  ./bootstrap --------------------------------------------- CMake 3.17.2, Copyright 2000-2020 Kitware, Inc. and Contributors Found GNU toolchain C compiler on this system is: gcc C++ compiler on this system is: g++  -std=gnu++11 Makefile processor on this system is: gmake g++ has setenv g++ has unsetenv g++ does not have environ in stdlib.h g++ has stl wstring g++ has <ext/stdio_filebuf.h> --------------------------------------------- g++  -std=gnu++11      -DCMAKE_BOOTSTRAP      -I/home/webadm/lnx/cmake-3.17.2/Bo                                                 otstrap.cmk   -I/home/webadm/lnx/cmake-3.17.2/Source   -I/home/webadm/lnx/cmake-                                                 3.17.2/Source/LexerParser   -I/home/webadm/lnx/cmake-3.17.2/Utilities/std   -I/h                                                 ome/webadm/lnx/cmake-3.17.2/Utilities  -c /home/webadm/lnx/cmake-3.17.2/Source/c                                                 mAddCustomCommandCommand.cxx -o cmAddCustomCommandCommand.o In file included from /home/webadm/lnx/cmake-3.17.2/Source/cmStringAlgorithms.h:                                                 18:0,                  from /home/webadm/lnx/cmake-3.17.2/Source/cmGlobalGenerator.h:2                                                 5,                  from /home/webadm/lnx/cmake-3.17.2/Source/cmAddCustomCommandCom                                                 mand.cxx:13: /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:151:42: 錯誤:expected 「;」 at e                                                 nd of member declaration /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:152:3: 錯誤:expected unqualified                                                 -id before 「{」 token /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:155:3: 錯誤:expected 「;」 at en                                                 d of member declaration /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:157:41: 錯誤:expected 「;」 at e                                                 nd of member declaration /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:157:11: 錯誤:「cmRange<Iter> cmR                                                 ange<Iter>::advance(cmRange<Iter>::difference_type)」 無法被多載 /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:151:12: 錯誤:與 「cmRange<Iter>&                                                  cmRange<Iter>::advance(cmRange<Iter>::difference_type)」 /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:158:3: 錯誤:expected unqualified                                                 -id before 「{」 token /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:161:3: 錯誤:expected 「;」 at en                                                 d of member declaration /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:163:42: 錯誤:expected 「;」 at e                                                 nd of member declaration /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:164:3: 錯誤:expected unqualified                                                 -id before 「{」 token /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:167:3: 錯誤:expected 「;」 at en                                                 d of member declaration /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:169:41: 錯誤:expected 「;」 at e                                                 nd of member declaration /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:169:11: 錯誤:「cmRange<Iter> cmR                                                 ange<Iter>::retreat(cmRange<Iter>::difference_type)」 無法被多載 /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:163:12: 錯誤:與 「cmRange<Iter>&                                                  cmRange<Iter>::retreat(cmRange<Iter>::difference_type)」 /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:170:3: 錯誤:expected unqualified                                                 -id before 「{」 token /home/webadm/lnx/cmake-3.17.2/Source/cmRange.h:173:3: 錯誤:expected 「;」 at en                                                 d of member declaration gmake: *** [cmAddCustomCommandCommand.o] Error 1 --------------------------------------------- Error when bootstrapping CMake: Problem while running gmake --------------------------------------------- Log of errors: /home/webadm/lnx/cmake-3.17.2/Bootstrap.cmk/cmake_bootstrap.log --------------------------------------------- [root@www cmake-3.17.2]#   https://zach.vip/server/%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85php7-4/ http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=593&blogId=70 Mon, 25 May 2020 13:48:54 +0800 20200513用JavaScript產生卡拉茲數列並一一PUSH入b陣列中,再一一自b陣列POP出來 (0)卡拉茲猜想:取任意一個自然數m,若m是偶數,執行m/2;若m是奇數,則執行3m+1,如此反覆疊代下去,必定會落入到4,2,1的陷阱中來。 我們隨便測試幾個數吧,比如17:52‑>26->13->40->20->10->5->16->8->4->2->1; 原文網址: https://kknews.cc/news/5e8342l.html (1) 在notepad(記事本)輸入如下程式碼並存檔為d:\a.htm(存檔類型要選所有檔案) <body bgcolor=lightblue> <script> var b=[]; var x= parseInt(prompt("請輸入x=","7")); document.write("你輸入的x=" + x + "<br>"); do  {   b.push(x);  document.write( x +  " : ");   if (x % 2==0 ) x= parseInt(x / 2);   else x=3*x+1; } while (x > 1); b.push(x);  document.write( x + ":將卡拉茲數列一一PUSH到堆疊b完成。<br>"); document.write("將堆疊b中的卡拉茲數列一一POP出來如下:<br>"); while (b.length > 0) {     x=b.pop();     document.write( x + " : ");     } </script> </body> (2)用firefox開啟d:\a.htm,瀏覽結果如下: 你輸入的x=7 7:22:11:34:17:52:26:13:40:20:10:5:16:8:4:2:1:將卡拉茲數列一一PUSH到堆疊b完成 將堆疊b中的卡拉茲數列一一POP出來如下: 1 : 2 : 4 : 8 : 16 : 5 : 10 : 20 : 40 : 13 : 26 : 52 : 17 : 34 : 11 : 22 : 7 :   (3)可參考的JavaScript程式 20200407商經一教室座位隨機重排avaScript網頁程式 20200131用JavaScript將輸入文字盒中的WGS84大地座標轉為kml及GPX航點及航跡字串 20200102用JavaScript設計二分搜尋法 20191230用JavaScript設計插入與選擇排序法 20191223用記事本編寫可找前三名及飛機航班追蹤模擬的JavaScript程式 20191221用記事本編寫JavaScripts網頁前端程式、遞廻程式碼 20191216在jsbin.com網站編寫JavaScript程式將結果抓入writer再轉存為pdf再上傳至「金門農工學生學習歷程系統」成IT學習檔案 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=591&blogId=70 Wed, 13 May 2020 15:30:07 +0800 20200430用LibreOffice的scalc進行迴歸分析 (一)製作f(x)=2x+1的線性迴歸線  (1-1)在scalc中新增一工作表(工作表名為y=2x+1)並在A1:C10輸入如下九筆資料 (1-2)選B1:C10/插入/圖表/xy(散佈)圖/挑僅顯示點/點選目前xy圖中的任一資料點/按右鍵/插入趨勢線/迴歸類型挑「線性」/勾顯示方程式及顯示決定係數,成功出現如下迴歸分析趨勢圖。 (二)製作f(x)=x^2的線性迴歸線 (2-1)在scalc中新增另一工作表(工作表名為y=x^2)並在A1:C10輸入如下九筆資料 (2-2)選B1:C10/插入/圖表/xy(散佈)圖/挑僅顯示點/點選目前xy圖中的任一資料點/按右鍵/插入趨勢線/迴歸類型挑「指數」/勾顯示方程式及顯示決定係數,成功出現如下迴歸分析趨勢圖。 (2-3)迴歸線處按右處刪除(2-2)的線,在同(2-2)插入另一條迴歸線,但本次迴歸類型挑2次方,結果如下。 (三) 參考範例:20200506LinearTrend.ods 下載 (14 KB) | created 06 五月, 2020   (四) 使用scalc輸入如下資料(20200505scalc_knn.ods 下載 (12 KB))並上傳至你的google雲端硬碟並製作w-h散佈圖:  no w h kind 101 3.5 46 南極企鵝 102 1.3 40 小藍企鵝 103 4.1 61 南極企鵝 104 2.1 48 加拉帕戈企鵝 105 2.5 50 加拉帕戈企鵝 106 1.2 39 小藍企鵝 107 1.1 43 小藍企鵝 108 2.6 53 加拉帕戈企鵝 109 1.4 44 小藍企鵝 110 3.9 59 南極企鵝 http://oldwww.kmvs.km.edu.tw/lf/index.php?op=ViewArticle&articleId=588&blogId=70 Thu, 30 Apr 2020 07:53:17 +0800