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