我有一些循环:
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/