10進数を印刷しようとしています。 "##### + 3.01" ケース:小数点はありません(この場合は3.01とします)。私はその記号+/-を先にy noで印刷しなければなりません。 #、いくつかの合計の幅を修正します。 (この場合、x = 10とします)。C++でsetfill()を使用して特定の形式の10進数を出力します。
私はこのような何かを試してみました:
double no = 3.01; cout << setfill('#') << setw(10) ; cout << setiosflags(ios::showpos); cout << fixed << setprecision(2) << no << endl;
しかし、私はfollowinfg出力取得しています:
+#####3.01
予想される出力:
を#####+3.01
可能な複製(https://stackoverflow.com/questions/ 46729847/stdostringstream-puts-sign-in-wrong-location) – Barmar