PIXNET Logo登入

KwCheng's blog

跳到主文

Blog for Computer Science ...

部落格全站分類:圖文創作

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 3月 29 週六 201418:08
  • format my source code to html

http://formatmysourcecode.blogspot.tw/
(繼續閱讀...)
文章標籤

JerryCheng 發表在 痞客邦 留言(0) 人氣(51)

  • 個人分類:my_c_lib
▲top
  • 3月 29 週六 201418:05
  • relative prime (互質)

int hcf(int a , int h)
{
int temp;
while(1)
{
temp = a % h;
if(temp == 0)
{
return h;
}
a = h;
h = temp;
}
}

int relativePrimes(int* num , int n)
{
int count = 0;
for(int i = 0 ; i < n ; i++)
{
for(int j = i + 1 ; j < n ; j++)
{
int a = *(num + i);
int b = *(num + j);
int gcd = hcf(a , b);
if(gcd == 1)
{
count++;
}
}
}
return count;
}
(繼續閱讀...)
文章標籤

JerryCheng 發表在 痞客邦 留言(0) 人氣(194)

  • 個人分類:my_c_lib
▲top
  • 3月 29 週六 201418:04
  • gcd - greatest common divisor

int hcf(int a , int h)
{
int temp;
while(1)
{
temp = a % h;
if(temp == 0)
{
return h;
}
a = h;
h = temp;
}
}
(繼續閱讀...)
文章標籤

JerryCheng 發表在 痞客邦 留言(0) 人氣(7)

  • 個人分類:my_c_lib
▲top
  • 3月 29 週六 201418:03
  • combination by pascal formula

int combination_pascal(int n , int r)
{
if(r == 0 || n == r)
{
return 1;
}
return combination_pascal(n - 1 , r) + combination_pascal(n - 1 , r - 1);
}
(繼續閱讀...)
文章標籤

JerryCheng 發表在 痞客邦 留言(0) 人氣(1)

  • 個人分類:my_c_lib
▲top
  • 3月 29 週六 201418:02
  • combination

int factor(int n)
{
int ret = 1;
for(int i = 2 ; i <= n ; i++ )
{
ret = ret * i;
}
return ret;
}

int combination(int n , int r)
{
int ret = factor(n) / (factor(r) * factor(n-r));
return ret;
}
(繼續閱讀...)
文章標籤

JerryCheng 發表在 痞客邦 留言(0) 人氣(3)

  • 個人分類:my_c_lib
▲top
  • 3月 29 週六 201418:01
  • scan n numbers into array

int* numArray(int n)
{
int* num = (int*)malloc(n * sizeof(int));

for(int i = 0 ; i < n ; i++)
{
scanf("%d\n" , num + i);
}

return num;
}
(繼續閱讀...)
文章標籤

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

  • 個人分類:my_c_lib
▲top
  • 3月 29 週六 201417:32
  • factor

int factor(int n)
{
int ret = 1;
for(int i = 2 ; i <= n ; i++ )
{
ret = ret * i;
}
return ret;
}
(繼續閱讀...)
文章標籤

JerryCheng 發表在 痞客邦 留言(0) 人氣(4)

  • 個人分類:my_c_lib
▲top
1

個人資訊

JerryCheng
暱稱:
JerryCheng
分類:
圖文創作
好友:
累積中
地區:

熱門文章

  • (126)Matlab - 內建變數
  • (9,406)notepad++ - 使用notepad++對文字進行轉碼
  • (444)Mathematics - 判斷point是否在triangle內
  • (34,773)Cpp - ifstream (read file) - 開檔 & 讀檔
  • (66)Solaris - svcs command

文章分類

toggle Software (5)
  • Notepad++ (1)
  • Graphviz (0)
  • Windows (1)
  • Eclipse (8)
  • Sloaris (5)
toggle Programming (11)
  • my_c_lib (7)
  • Shell programming (12)
  • C / Cpp (75)
  • Python (9)
  • Html/CSS (2)
  • JavaScript (18)
  • JSP (4)
  • Matlab (13)
  • PHP (1)
  • SQL (7)
  • Java (59)
toggle Information Retrieval (2)
  • Information Retrieval (7)
  • IR - Lemur (2)
  • Solaris (3)
  • Mathematics (4)
  • computer science (4)
  • Linux (17)
  • Statistics (1)
  • 未分類文章 (1)

最新文章

  • python - time
  • python - thread
  • Javascript - class
  • shell - while loop
  • expect - sftp example
  • javascript injection
  • [轉錄] ls color setting
  • python - inheritance & template pattern
  • sorting by value of dictionary
  • Browse all elements of array

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

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