gpt4 book ai didi

c++ - 制表问题

转载 作者:行者123 更新时间:2023-11-27 23:29:32 26 4
gpt4 key购买 nike

我有一些循环:

for(int i=0; i<rolls; i++)
{
first = rand()%6+1;
second = rand()%6+1;
cout<<'('<<first<<')';
for(int j=0; j<first; j++)
{
cout<<'*';
}
cout<<'\t'<<'('<<second<<')';
for(int j=0; j<second; j++)
{
cout<<'*';
}
cout<<endl;
}

它运行良好,但我的输出有一些问题:

CPU             Player
(2)** (3)***
(4)**** (1)*
(6)****** (5)*****
(5)***** (6)******
(1)* (5)*****
(3)*** (1)*
(4)**** (2)**
(3)*** (1)*
(1)* (5)*****
(5)***** (4)****
(2)** (6)******
(5)***** (3)***

这个表格有什么问题吗?

最佳答案

\t 依赖于依赖于您的环境的制表位。

相反,您应该查看 iomanip header用于指定最小列跨度。另见 this answer .

关于c++ - 制表问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6499353/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com