各位 这个数字怎么让他右对齐呀
只会靠左输出 不知道怎么靠右 就是6下面是54321 而不是空的
麻烦大家了
#include <iostream>
using namespace std;
int main()
{
for (int i = 6; i >= 1; i--)
{
for (int j = 1; j <= 6 - i; j++)
cout << " ";
for (int j = 1; j <= i; j++)
cout << j << ' ';
cout << '\n';
}
return 0;
}
$ g++ -Wall main.cpp
$ ./a.out
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
我用#CSDN#这个app发现了有技术含量的博客,小伙伴们求同去《C++的输入输出 I/O流控制》, 一起来围观吧 https://blog.csdn.net/weixin_62264287/article/details/123391849?utm_source=app&app_version=5.3.0&code=app_1562916241&uLinkId=usr1mkqgl919blen