?? fmtnum.h
字號:
/* 2008 (c) Dorival M. Pedroso */#ifndef MPM_FMTNUM_H#define MPM_FMTNUM_H// STL#include <iostream>#include <iomanip>/** Formatting Numbers via STL streams. */struct FmtNum{ bool BoolAlpha; ///< Format output as a boolean? bool Integer; ///< Format output as an integer? bool Scientific; ///< Format output as a scientific number? int Width; ///< Width of the output int Precision; ///< Precision for floating point numbers};// bool integ scien w pFmtNum _a = { true, false, false, 0, 0 }; ///< BooleanFmtNum _3 = { false, true, false, 3, 0 }; ///< IntegerFmtNum _4 = { false, true, false, 4, 0 }; ///< IntegerFmtNum _6 = { false, true, false, 6, 0 }; ///< IntegerFmtNum _8 = { false, true, false, 8, 0 }; ///< IntegerFmtNum _3s = { false, false, true, 0, 3 }; ///< ScientificFmtNum _8s = { false, false, true, 0, 8 }; ///< ScientificFmtNum _4_2 = { false, false, false, 4, 2 }; ///< GeneralFmtNum _6_3 = { false, false, false, 6, 3 }; ///< GeneralFmtNum _12_6 = { false, false, false, 12, 6 }; ///< GeneralFmtNum _20_15 = { false, false, false, 20, 15 }; ///< General/** Format the output. */std::ostream & operator<< (std::ostream & os, FmtNum const & FN){ if (FN.BoolAlpha) { os<<" "<<std::setw(6)<<std::boolalpha; return os; } else if (FN.Integer) { os<<" "<<std::setw(FN.Width); return os; } else if (FN.Scientific) { os<<" "<<std::setw(FN.Precision+9)<<std::scientific<<std::setprecision(FN.Precision); return os; } // add 9 else { os<<" "<<std::setw(FN.Width+1)<<std::fixed<<std::setprecision(FN.Precision); return os; } // add 1 (for sign)}#endif // MPM_FMTNUM_H/* 2008 (c) Dorival M. Pedroso */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -