推 hateexam:第三題 前三個給定初始值f(1)=1,f(2)=2,f(3)=5 03/26 11:01
1.Decode the following ASCII code: 1010011 1110100 1100001 1110010 0110010
(hint: ASCII (0)=30H, ASCII (A)=41H, ASCII (a)=61H)
ps.請問這個要怎麼做解碼呢?
2. Here is a series of address references given as word addresses:
1, 4, 8, 5, 20, 17, 19, 56, 9, 11, 4, 43, 5, 6, 9, 17
Assuming a direct-mapped cache with 16 one-word blocks that is initially
empty, label each reference in the list as a hit or a miss and show the final
contents of the cache.
PS.這題看不懂題目 也不會算耶 請大大幫忙解惑喔
3.Given the Fibonacci number as
1 2 5 8 13 21 ……
Write an object-oriented program to generate the Fibonacci number N
int fibonacci(int n)
{
if(n <= 0)
return 0;
else if(n = = 1)
return 1;
else
return fibonacci(n-1) + fibonacci(n-2);
}
上面是我自己寫的@@ 可是感覺上題目要我寫得好像不是這個程式碼耶
因為題目給的前面兩個數相加 並沒有等於第三個數
比如題目給 1 2 1+2 ≠ 5 2+5≠8
但是從第三個數字 就是8+5=13 8+13=21 (前面兩個數相加 等於第三個數)
所以是我上面程式碼還要再做怎樣的更改呢?
還是說這就是對的程式碼呢?
先謝謝大大的解惑唷~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.161.128.117