--- tags: DICE C --- 16-10 自主學習 === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- 題目 -- ```! 令: f(1)=10,f(2)=15,f(3)=16 f(n)={f(n-2)+f(n-3),當n>=4} 請寫一個程式,輸入n,輸出f(n)值。 輸入範例: 5 輸出範例: 31 ``` 程式碼 -- ```c= #include <stdio.h> int f(int n) { if (n == 1) return 10; if (n == 2) return 15; if (n == 3) return 16; return f(n - 2) + f(n - 3); } int main() { int n; scanf("%d", &n); printf("%d", f(n)); return 0; } ``` 執行 -- ```! 5 31 ``` --- [查看我們在HackMD上的所有筆記](https://hackmd.io/@CHAWTeam) 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height=210 src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-16-10" width="100%"></iframe> --- {%hackmd i1nMRrZcTFmTvoF897K9zg %}
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up