PIXNET Logo登入

Frank's 資訊科技潮流站

跳到主文

介紹最新的資訊技術及應用

部落格全站分類:數位生活

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 5月 06 週一 201300:04
  • [演算法] 動態規劃 Dynamic Programming

動態規劃
1. 大問題可以分解為子問題
2. 每一個子問題的答案可以被儲存起來 供下次直接取用 不必再重新計算
 
(繼續閱讀...)
文章標籤

finalfrank 發表在 痞客邦 留言(1) 人氣(2,710)

  • 個人分類:演算法
▲top
  • 7月 05 週四 201200:39
  • [離散數學] 算術平均數、中位數、眾數表示方法

daLet A sequence of number be
A1,A2,…..,Ai,…..,An in an increasing order  
N is the number of elements
(繼續閱讀...)
文章標籤

finalfrank 發表在 痞客邦 留言(0) 人氣(577)

  • 個人分類:演算法
▲top
  • 7月 29 週二 200803:51
  • 用 遞迴( recurrence ) 做出 多重迴圈 ( nested loop )


Multiple Loop
To Recurrence Function


(繼續閱讀...)
文章標籤

finalfrank 發表在 痞客邦 留言(0) 人氣(3,107)

  • 個人分類:演算法
▲top
  • 11月 23 週五 200716:41
  • 割圓術算不出無限位數的 pi...π

割圓術到底能不能算出無限位數的 pi π呢......?
首先呢,我們要先知道圓形的一個公式
Here's the formula of a round.
其中,  r   是半徑
r is the radius of the round.
運用這個公式,我們可以求得在一個圓形上出現的所有座標
Using this formula, we can get all the positions of the round.
但是可想而知,如果圓上面,每個座標都要求到...
其實是有無限多個!
所以,我們就把顯示座標限制在 
     _____   _____
( √整數 , √整數   )

However, the number of the positions on the round...is infinite..
So, we just show the positions that are square roots of integers.
     _____      _____
( √Integer, √Integer  )
(繼續閱讀...)
文章標籤

finalfrank 發表在 痞客邦 留言(0) 人氣(1,100)

  • 個人分類:演算法
▲top
  • 11月 17 週六 200723:45
  • 最大公因數 & 最小公倍數 計算機 L.C.M. & G.C.D. Calculator


可以一次計算多個數值的最大公因數 最小公倍數
[ 按此下載 ]
[ English Version is Available ]
程式碼 (僅供學習參考用) :
#include<stdio.h>
#include<stdlib.h>
int lcm(int a,int b);
int gcd(int c,int d,int e);
int main(void)
{
   
    int g=1,get[10],c,re,re2,re3,gcd2,k;
       
    printf(" 《最大公因數、最小公倍數 計算機》 \n");
while(g=g)
{
      
    while(g==g)
    {
      printf("\n請輸入第 %d 個數值 ,輸入 0 開始計算: ",g);
      scanf("%d",&get[g]);
     
      gcd2=get[g-1];
     
      if(get[g]==0)
        break;
     
      g++;
    }
   
    g--;
   
    for(k=1;k<=g;k++) /* 排序,從小的數值排到大的 */
    {
      for(int i=1;i<=g;i++)               
      {
        if(get[k]>get[i])
          c=get[k],get[k]=get[i],get[i]=c;
      }
    }    
   
    re=re2=get[g];
             
    while(g>=2)
    {
     re3=re2;
    
     re=lcm(re,get[g-1]);
    
     re2=lcm(get[g],get[g-1]);  /* 計算 這次 最小公倍數 */
     re2 = gcd(get[g],get[g-1],re2); 
     gcd2 = lcm(re2,re3); /* 計算 這次 和 上次 最小公倍數 的 最大公因數 */
     gcd2 = gcd(re3,re2,gcd2); /* 計算 這次 和 上次 最小公倍數 的 最小公倍數 */
    
     g--;
        
    }
     printf("\n最大公因數 : %d\n\n最小公倍數 : %d\n\n=====================================",re,gcd2);
    
   g=1;
  
   printf("\n\n請輸入第 %d 個數值 ,輸入 0 離開程式: ",g);
      scanf("%d",&get[g]),g++;
     
      if(get[1]==0)
      {
        printf("\n");          
        break;
      }
}
}
   
   
int lcm(int a,int b)
{
    int c=b;
   
    if(a<b)
    c=a,a=b,b=c; /* a b 互換 */
   
    b=a-b;
   
    if(b!=0)
    {   
     while(a%b!=0)
     {
      c=b;
      b=a%b;
      a=c;
     }
    }
    else
    b=c;
   
    return b;
   
}
int gcd(int c,int d,int e)
{
    e = c * d / e;
         
    return e;
   
}

Code ( for reference only ):
#include<stdio.h>
#include<stdlib.h>
int lcm(int a,int b);
int gcd(int c,int d,int e);
int main(void)
{
   
    int g=1,get[10],c,re,re2,re3,gcd2,k;
       
    printf(" < LCM & GCD CALCULATOR > \n");
while(g=g)
{
      
    while(g==g)
    {
      printf("\nEnter #%d Value , Enter 0 to begin calculate : ",g);
      scanf("%d",&get[g]);
     
      gcd2=get[g-1];
     
      if(get[g]==0)
        break;
     
      g++;
    }
   
    g--;
   
    for(k=1;k<=g;k++) /* Sort, from small to big */
    {
      for(int i=1;i<=g;i++)               
      {
        if(get[k]>get[i])
          c=get[k],get[k]=get[i],get[i]=c;
      }
    }    
   
    re=re2=get[g];
             
    while(g>=2)
    {
     re3=re2;
    
     re=lcm(re,get[g-1]);
    
     re2=lcm(get[g],get[g-1]);  /* Calculate the lcm this round */
     re2 = gcd(get[g],get[g-1],re2); 
     gcd2 = lcm(re2,re3); /* Calculate the lcm of the gcd of this round and last round */
     gcd2 = gcd(re3,re2,gcd2); /* Calculate the gcd of the gcd of this round and last round */
    
     g--;
        
    }
     printf("\nL C M : %d\n\nG C D : %d\n\n=====================================",re,gcd2);
    
   g=1;
  
   printf("\n\nEnter #%d Value , Enter 0 to exit : ",g);
      scanf("%d",&get[g]),g++;
     
      if(get[1]==0)
      {
        printf("\n");          
        break;
      }
}
}
   
   
int lcm(int a,int b)
{
    int c=b;
   
    if(a<b)
    c=a,a=b,b=c; 
   
    b=a-b;
   
    if(b!=0)
    {   
     while(a%b!=0)
     {
      c=b;
      b=a%b;
      a=c;
     }
    }
    else
    b=c;
   
    return b;
   
}
int gcd(int c,int d,int e)
{
    e = c * d / e;
         
    return e;
   
}

(繼續閱讀...)
文章標籤

finalfrank 發表在 痞客邦 留言(0) 人氣(8,937)

  • 個人分類:演算法
▲top
  • 10月 29 週一 200723:22
  • 楊輝三角形 ( 巴斯卡三角形 ) ( Pascal's triangle )


巴斯卡三角形
Pascal's Triangle

[ 演算程式  ]
[  Pascal's Triangle Computer ( English Version )  ]

0 1 0 0 0 0
0 1 1 0 0 0
0 1 2 1 0 0
0 1 3 3 1 0
0 1 4 6 4 1
計算原理:如上面文字所列
每一格的數值即是( x , y )  ,其中 y 是由上往下數
套入公式  ( x , y ) = ( x-1 , y -1 ) + ( x , y-1 )        
使用陣列,馬上就能寫出來
Every number existed in the triangle can be expressed like ( x , y ) = ( x - 1 , y -1 ) + ( x , y - 1 )
Please notice that the " y " here , is counted from up to down.
( For example : ( 2 , 1 ) = 0      ( 2 , 2 ) = 1      ( 3 , 3 ) = 3  )
You can try to write a script to compute this triangle using the formula above. ( It's recommended to use array. )
在數學上的應用:
Usage of Pascal's Triangle in Mathematics

原始碼 (使用最省記憶、最有效率的寫法)
#include<stdio.h>
#include<stdlib.h>
int  main ()
{
     int phase[34][2],counter,x,row,y;
       
    printf("  《楊輝三角形產生器》\n\n本程式可以輸出你輸入的列數\n\n任何時候都可以輸入-1離開\n\n(32位元電腦只支援到34行)\n\n ");
   
    while(x==x)/* 無限迴圈開始 */
    {         
     for(x=0;x<=34;x++) /* 清空變數 */
    {
      for(y=0;y<=1;y++)
        phase[x][y]=0;
    }
       
     printf("請輸入顯示列數 : ");
     scanf("%d",&counter);
    
     printf("\n");
     if(counter>=35)
       counter=34;
     if(counter==-1) /* 使用者輸入 -1 離開 */
        break;
             
     phase[0][0]=1; /* 初始化計算用數值 */
    
     row=1;
    
       while(row<=counter) /* 程式跑到指定列數才結束 */
       {                                     
           for(x=1;x<=counter-row;x++) /* 美化用的迴圈... */
            printf(" ");
        for(x=1;x<=row;x++) /* 計算並顯示數值 */
        {
            phase[x][1]=phase[x-1][0]+phase[x][0];
            printf(" %d",phase[x][1]);
      
        }
       
          for(x=0;x<=row;x++) /* 放入這個迴圈的數值 讓下個迴圈計算 */
            phase[x][0]=phase[x][1];
      
       row++; /* 跑的列數 +1 */
    
       printf("\n\n");   
       }
     } /* 無限迴圈結束 */
     printf("(c) NTPU CSIE 49571602\n\n");
    
     system("pause");
    
     return 0;
} 

Pascal's Triangle Code. ( White Texts Hidden Below, for your reference. )
(Using the most efficient method, which saves most memory that I've ever tried.)
#include<stdio.h>
#include<stdlib.h>
int  main ()
{
     int phase[34][2],counter,x,row,y;
       
    printf("  << Pascal's Triangle Computer >>\n\nThis program computes the number of line you requested.\n\nYou may exit any time by typing -1\n\n( A 32-bit computer is limited to display less than 34 lines. )\n\n ");
   
    while(x==x)
    {         
     for(x=0;x<=34;x++)
    {
      for(y=0;y<=1;y++)
        phase[x][y]=0;
    }
       
     printf("For How many Lines would you like to Compute : ");
     scanf("%d",&counter);
    
     printf("\n");
     if(counter>=35)
       counter=34;
     if(counter==-1)
        break;
             
     phase[0][0]=1;
    
     row=1;
    
       while(row<=counter)
       {                                     
           for(x=1;x<=counter-row;x++)
            printf(" ");
        for(x=1;x<=row;x++) /* 計算並顯示數值 */
        {
            phase[x][1]=phase[x-1][0]+phase[x][0];
            printf(" %d",phase[x][1]);
      
        }
       
          for(x=0;x<=row;x++)
            phase[x][0]=phase[x][1];
      
       row++;
    
       printf("\n\n");   
       }
     }
     printf("(c) NTPU CSIE 49571602\n\n");
    
     system("pause");
    
     return 0;
} 



(繼續閱讀...)
文章標籤

finalfrank 發表在 痞客邦 留言(0) 人氣(4,109)

  • 個人分類:演算法
▲top
1

.

文章搜尋

從【分類】找文章

toggle 趨勢 Trends (1)
  • 發展趨勢 (11)
toggle 電腦視覺 Computer Vision (5)
  • 實驗用作品 (3)
  • 圖形識別 (1)
  • 立體視覺 (2)
  • 相關研究 (7)
  • 電腦視覺論文摘要 (1)
toggle 影像處理 Image Processing (9)
  • 影像處理軟體教學 (1)
  • 作品分享 (21)
  • 背景知識 (1)
  • 相關研究 (5)
  • 影像處理技巧 (7)
  • 影像與視訊壓縮 (3)
  • 影像拼接 (3)
  • 影像處理書報摘要 (1)
  • 高動態範圍HDR (1)
toggle 電腦圖學 Computer Graphics (3)
  • 相關作品 (1)
  • 數位網格 (1)
  • 圖學引擎設計 (6)
toggle 人工智慧 Artificial Intelligence (3)
  • 機器學習 (2)
  • 人工智慧書報摘要 (1)
  • 人工智慧作品分享 (2)
toggle 法學資訊系統 Law System (1)
  • 網頁版成品 (1)
toggle 資料庫與雲端運算 Database&Cloud (3)
  • AJAX (2)
  • 網頁設計 (4)
  • 開發筆記 (3)
toggle 電腦網路 Computer Networks (3)
  • 網路程式設計 (1)
  • 實用網管 (5)
  • 理論知識 (1)
toggle 演算法與資料結構 Algo. & DS. (6)
  • 離散數學 (1)
  • 經典題目 (3)
  • 資料結構 (7)
  • 演算法 (6)
  • 學習 (2)
  • 作品分享 (1)
toggle 程式設計 Programming (5)
  • Android 開發 (1)
  • Windows (1)
  • 程式寫作教學 (7)
  • Ruby (4)
  • 作品分享 (19)
toggle 遊戲設計 Game Design (3)
  • RPG Maker (7)
  • 遊戲引擎設計 (6)
  • 作品發表 (12)
toggle 電腦醫院 Computer Doctor (1)
  • 綜合診所 (8)
toggle 其他 (3)
  • 電腦使用技巧 (2)
  • 學習雜項 (6)
  • 遊記 (22)
  • 研究方法 (2)
  • 未分類文章 (1)

Ga

文章彙整

參觀人氣

  • 本日人氣:
  • 累積人氣: