Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;多列对齐_C++_Format_Setw - Fatal编程技术网

C++ C++;多列对齐

C++ C++;多列对齐,c++,format,setw,C++,Format,Setw,我正试图写一个程序来显示每个月的帐户余额,但在获得正确的3列时遇到了一个问题。预期的输出应如下所示: Total Month Accumulated ------ ----------- 2015 March 500.00 2015 April 1001.13 2015 May 1503.38 2015 June

我正试图写一个程序来显示每个月的帐户余额,但在获得正确的3列时遇到了一个问题。预期的输出应如下所示:

                 Total  
Month            Accumulated  
------           -----------  
2015 March            500.00  
2015 April           1001.13  
2015 May             1503.38  
2015 June            2006.76  
2015 July            2511.28
但我的输出如下所示:

                 Total  
Month            Accumulated  
------           -----------  
2015 March            500.00  
2015 April            1001.13  
2015 May              1503.38  
2015 June             2006.76  
2015 July             2511.28
我需要让数字在右边均匀排列。我似乎无法用正确的理由让它看起来更接近我需要的东西。我希望这里的某个人可能有一个我忽略了的简单解决方案。目前,该行是这样写的:

cout << setw(5) << left << currentYear << setw(18) << currentMonthName << totalAccum << endl;

cout我想出来了-需要添加一个“”作为占位符,然后进行正确的对齐:
std::setw()