php - C语言算法题-开灯问题 代码有点看不懂求大神指点?
巴扎黑
巴扎黑 2017-04-18 10:33:11
0
3
561

巴扎黑
巴扎黑

reply all(3)
阿神

The code you circled is the statement that outputs the results. This means that there is no space before the first output number, and each subsequent number adds a space to the previous number.
first is a flag bit. It is first assigned a value of 1 and is judged during the loop output. At this time, first=1, which is the first result output. Then print the result directly and set first to 0. Then print the subsequent output. At this time, first=0 (not the first number), then output a space first and then print the number.

迷茫

1 5 6 7 in the example is actually 1[space]5[space]6[space]7[space]

If it is the first unfolded light (first is true), only modify the flag bit to false (do not output " ") and then output the number of the light. If it is not the first displayed light (judge whether it is the first displayed light) first has been set to 0), first output " " and then the number

伊谢尔伦

....Isn’t this just to use spaces to divide the resulting numbers....
Otherwise they would all be connected 1567

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!