求助 输出结束后留有空格和换行的影响
查看原帖
求助 输出结束后留有空格和换行的影响
1060148
GaIaxy楼主2023/10/26 15:41

请教

题目说结尾不要留有换行和空格,但是测试了一下,并没有影响正确性

那么测试点是如何比较答案的正确与否的,为什么多余的输出没有影响呢

下面这个输出部分严格按照要求 不留空格和换行 AC

cout << nums[0];
	for_each(nums.begin() + 1, nums.end(), [](int val){
		cout << ' ' << val;
	});

这两个留有空格和换行 仍为AC

cout << nums[0];
for_each(nums.begin() + 1, nums.end(), [](int val){
		cout << ' ' << val;
	});
cout << ' ' << '\n';
cout << nums[0];
for_each(nums.begin() + 1, nums.end(), [](int val){
		cout << ' ' << val;
	});
cout << ' ' << '\n' << '\n' << '\n' << '\n' << '\n' << '\n';
2023/10/26 15:41
加载中...