Task Description
f91
McCarthy是一個有名的資訊專家。他定義了一個遞迴的函數叫做 f91 。它輸入一個正整數N並且依據以下的規則傳回一個正整數:
如果 N <= 100, 那麼 f91(N) = f91( f91( N+11) )
如果 N >= 101, 那麼 f91(N) = N-10
請你寫一個程式來計算 f91
Hint
f91.h
打上 function header 以及相關的設定。void f91(int n);
f91.c
撰寫程式碼後對應上傳。#include "f91.h"void f91(int n) { / add your code /}
main.c
這個檔案無法更改也無須上傳。1234567891011 #include <stdio.h>#include "f91.h" int main(){ int n; scanf("%d", &n); printf("f91(%d) = %d\n", n, f91(n)); return 0; }
Input Format
測試資料為一正整數n。
Output Format
請撰寫一遞迴程式輸出f91函數的計算結果。
Sample Input
1 5
Sample Output
1 f91(5) = 91