知識社群登入
[程式練功區]C程式-Homework2
by 艾鍗學院, 2012-03-28 17:39, 人氣(2607)
1) Write and test a Fibonacci() function that uses a loop instead of recursion to calculate Fibonacci numbers.

f(n)=f(n-1)+f(n-2) if n > 2
f(n)=n             if  0<=n<=2 


2) Write a routine that rotates the bit pattern for the character c left b bits.
 
  unsigned char rotate_left(unsigned char c, unsigned char b)
      
   ex.  rotate_left(0xa3,2) returns 0x8e
           


3) Write a to_base_n(int number,int base) function which prints the number that is its first argument to the number base given by the second argument. 
For example, to_base_n(129,8) would display 201, the base-8 equivalent of 129. 

Please implement to_base_n() function in Recursive version and Non-recursive version.



討論
編號標題回應最後發表
15214
1
0
15212
1
0