C++ 使用 TABS 间距

标签 c++ codeblocks

我正在尝试制作 cout<<intRate<<"\t\t";语句从不同的位置开始 cout <<"\t\t"<<monPayment; .我的问题是调整费率和付款值。

我得到的输出是什么:

Principal            Interest Rate


   0.07    0.075   0.08    0.085   0.09    0.095   0.1
_______________________________________________________________
100000  665.302 699.215 733.765 768.913 804.623 840.854 877.572
________________________________________________________________
Interest rate is greater than .10 and the value is.105

我试着让它看起来像这样:

Principal               Interest Rate


           0.07    0.075   0.08    0.085   0.09    0.095   0.1
_______________________________________________________________
100000  665.302 699.215 733.765 768.913 804.623 840.854 877.572
________________________________________________________________

Interest rate is greater than .10 and the value is .105

其中 0.07 与 665.302 对齐

最佳答案

很难从你的问题中判断出来,但听起来你正在寻找 iomanip

#include <iostream>
#include <iomanip>

int main()
{
    std::cout << setw(4) << 1 << setw(4) << 2 << std::endl;
}

输出:

1   2

关于C++ 使用 TABS 间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5124939/

相关文章:

c++ - 不使用 EOF 位作为我们的流提取条件的真正原因是什么?

C++ 类集,跳过前 2 个值

c++ - 从 `cmd` 文件启动的进程创建进程

c++ - 代码块断点忽略范围

c++ - SDL/SDL_image.h : No such file or directory

c++ - Code::Blocks - 奇怪的返回码

c++ - 在命名空间中使用全局命名空间中的函数

c++ - 如何在 C++ 中按字母顺序对标准输入字符串进行排序?

C++ 链接器错误 SDL 图像 - 无法读取符号

c++ - 有人知道一个好的、免费的 C++ 调试器吗?