Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は C プログラミングを学んでいます。このプロトタイプを使用して再帰関数を書こうとしていました。
void fact(int *n);
この関数のパラメーターは、参照渡しする必要があります。ご協力いただきありがとうございます。
完全な解決策を提供するのに役立つとは思いません。これは、答えがあることを示すためです。
void fact(int *n) { if (*n > 1) { int tmp = *n - 1; fact(&tmp); *n *= tmp; } }
このように階乗関数を書くことは決してありません。