This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Selectsort(x, n) | |
| int x[], n; | |
| { | |
| int i, index, j, large; | |
| for (i = n-1; i > 0; i--){ | |
| large=x[0];//要有初始值下面才能做判斷 | |
| index=0; | |
| for (j = 1; j <= i; j++){ | |
| If (x[j]>large){ | |
| large=x[j]; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Selectsort(x, n) | |
| int x[], n; | |
| { | |
| int i, index, j, small; | |
| for (i = 0; i <n; i++){ | |
| small=x[i];//要有初始值下面才能做判斷 | |
| index=i; | |
| for (j = i+1; j < n; j++){ | |
| if (x[j]<small){ | |
| small=x[j]; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | //首先建一個計數陣列長度為內容範圍最大值加1,即長度為10。 | |
| Int count[10]={0}; | |
| //計算元素出現次數存入計數陣列 | |
| for (int i =0; i<n; i++) { | |
| count[iArray[i]]+=1; | |
| } | |
| //建立輸出陣列 | |
| Int output [n]={0}; | |
| //遍歷計數陣列做排序 | |
| Int index=0; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Online Python compiler (interpreter) to run Python online. | |
| # Write Python 3 code in this online editor and run it. | |
| def count_reverse_sort(a): | |
| max=0 | |
| for i in a: | |
| if i>max: | |
| max=i | |
| count=[None]*(max+1) | |
| output=[None]*len(a) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Online Python compiler (interpreter) to run Python online. | |
| # Write Python 3 code in this online editor and run it. | |
| def count_sort(a): | |
| max=0 | |
| for i in a: | |
| if i>max: | |
| max=i | |
| count=[None]*(max+1) | |
| output=[None]*len(a) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def count_inversion(a): | |
| count=0 | |
| for i in range(len(a)): | |
| for j in range(i+1,len(a)): | |
| if a[i]>a[j]: | |
| count+=1 | |
| return count | |
| print(count_inversion([3, 1, 2, 4])) | |
| #output:2 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def merge_two_orderedlist(a, b): | |
| i, j = 0, 0 | |
| merged_list = [] | |
| # 比較兩個列表並將元素合併到merged_list | |
| while i < len(a) and j < len(b): | |
| if a[i] < b[j]: | |
| merged_list.append(a[i]) # 改為append | |
| i += 1 | |
| else: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | "file:_link.vim | |
| :abbr Vlang https://vlang.io/ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | "file:_vimrc | |
| "There are different file names on Windows or Linux. So we have to check the file name. | |
| if has('win32') | |
| let $MYLOCALVIMRC = $HOME . "/_link.vim" | |
| else | |
| let $MYLOCALVIMRC = $HOME . "/.link.vim" | |
| endif | |
| "Read our link file | |
| if filereadable($MYLOCALVIMRC) | |
| source $MYLOCALVIMRC | 
NewerOlder