學習程式設計過程中總會碰到疑難雜症,而這些疑難雜症又不是一時能解決,不論是以往或是從未遇過的,都可將這些在程式設計上所碰到問題的解決方法筆記下來,或許解決了就算了,但等到下次有相同問題時,可將這程式設計筆記再拿來參考,就不枉做筆記了。
#include <stdio.h>#include <math.h>int main(){ int n, j = 0; while (scanf("%d", &n) && n > 0 ) if (n != 1) printf("Case %d: %d\n", ++ j, (int)ceil(log((double)n)/log(2))); else printf("Case %d: 0\n", ++ j) ; return 0;}
沒有留言:
張貼留言