打印表 C++
我正在尝试打印一个如下所示的表格:
Number of Queues
Oc 2 3 4 5
50,000 average-max average-max average-max average-max
100,000 average-max average-max average-max average-max
150,000 average-max average-max average-max average-max
等等,
其中平均值是 getAverage() ,最大值是 getMax() 。
amount 包含步进的 Oc 值。
我一直试图用来执行此操作的代码如下:
cout << setw(5) << "Oc" << setw(10) << "2" << setw(5) << "3" << setw(5) << "4" << setw(5) << "5" << endl << endl;
while (amount < 400000)
{
amount += 50000;
for (int i = 2; i <= 5; i++) //2 and 5 for the number of queues
{
Simulator simulator(i, amount);
simulator.start();
cout << setw(5) << amount << setw(10) << simulator.getAverage() << "-" << simulator.getMax();
} //end for loop
} //end while loop
我需要一些帮助来修复此问题以正确显示表格,目前它到处都是。
I am trying to print a table that looks like this:
Number of Queues
Oc 2 3 4 5
50,000 average-max average-max average-max average-max
100,000 average-max average-max average-max average-max
150,000 average-max average-max average-max average-max
etc etc
where average is the getAverage() and max is the getMax().
amount contains the stepped Oc value.
The code I have been trying to use to do this is below:
cout << setw(5) << "Oc" << setw(10) << "2" << setw(5) << "3" << setw(5) << "4" << setw(5) << "5" << endl << endl;
while (amount < 400000)
{
amount += 50000;
for (int i = 2; i <= 5; i++) //2 and 5 for the number of queues
{
Simulator simulator(i, amount);
simulator.start();
cout << setw(5) << amount << setw(10) << simulator.getAverage() << "-" << simulator.getMax();
} //end for loop
} //end while loop
I need some help fixing this to display the table properly, it's all over the place at the moment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用“\t”
You can use "\t"
祝你好运
Good luck