我运行程序后数字都黏在一起了,没有分隔,想要数字会自动分隔,在VS2019中我应该如何操作才能实现想要的效果呢?
目前:
101103107109113127131137139149151157163167173179181191193197199
count = 21
想要效果:
101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199
count = 21
我运行程序后数字都黏在一起了,没有分隔,想要数字会自动分隔,在VS2019中我应该如何操作才能实现想要的效果呢?
目前:
101103107109113127131137139149151157163167173179181191193197199
count = 21
想要效果:
101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199
count = 21
关注c语言的话,printf("%d "a);空格即可。
下面这个方法c++/c都可以。
setw(函数可以了解一下)
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int a[3] = {1,2,3};
for (int i = 0; i < 3; i++)
{
cout << setw(2) << a[i]; //setw(n)
}
return 0;
}

1.