【发布时间】:2018-10-12 08:23:30
【问题描述】:
我正在尝试编写一个非常简单的 C++ 程序,它输出一个查找表,其中包含相应的 x 和 y 正弦函数值。我写的代码如下:
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double hw = 4.0;
int nsteps = 30;
const double PI = 3.14159;
const double maxx = hw * PI;
const double deltax = maxx / nsteps;
double x = 0.0;
for (int i = 0; i < nsteps; i++) {
const double f = sin(x);
cerr << x << "\t" << f << endl;
x = x + deltax;
}
return 0;
}
现在程序正在运行,但我的问题是,值没有正确对齐,如下图所示
那么有什么方法可以实现第二列值实际上是一列并且所有值都在同一位置对齐?我可以用什么来代替\t?
【问题讨论】:
标签: c++ console alignment text-alignment