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.
long double ans = fact(n); fprintf(out,"%lg",ans);
ドットの後に数字なしで long double を印刷するのに最適な (そして最短のバリアント) は何ですか? 何も思いつきません。フォーマット フラグ %lg はこのタスクでは使用できません。完全な数値を出力する必要があります。
//私の下手な英語で申し訳ありません.主なアイデアを理解していただければ幸いです..
printf ("%.0lg", var)小数点以下の数字なしでlong double変数を出力するために使用されます。var
printf ("%.0lg", var)
long double
var
小数部分が必要ない場合は、int (または long) として出力するのはどうですか? :
fprintf(out,"%d",(int)ans);