Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Why are the three digits in the %2d output array connected when calling the function to print the array?
Why are the three digits in the %2d output array connected when calling the function to print the array?
Because the "%3d" format symbol indicates that the output integer data takes up 3 bits, if the actual output data is greater than or equal to 3 bits, it will be output according to the actual data length, and if it is less than 3 bits, a space will be added before the output.

Because the data you output is less than 3 bits, there is a space in front of the output, and there is no space in front of more than 3 bits, so output together.

When "%3d" is changed to "%4d", it means that the output integer data takes up 4 bits. If it is less than 4 bits, a space is added before the output. Your data has only 3 digits, so there is a space in front of it.

However, these four digits will be output together. The solution is to output with the format character "%d" without specifying the width of integer data, and let it be output according to the actual length, followed by 1 spaces.

These two output methods specify the integer data width and do not specify the integer data width. If the columns are aligned, the integer data width is specified. If the columns are separated by spaces, the second method is used.