Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

How do you print a new line??

Правка en1, от Naaz, 2023-06-24 10:28:36

can you please tell me how do you print new line. after a a for loop.

	for (int i = 0; i < n; i++) {
		cout << i << " \n"[i == n - 1];
	}

As you can see in the above code it automatically prints newline when i == n-1. and I don't prefer to use ternery operator for this case. (It takes time to write. haha) But can this be done with printf(); Just asking. If it can be done please tell me how?

Happy Coding.

P.S : I use FastOlympicCoding extension in sublime text so it kind of takes into consideration the extra white at the end and does not give correct answer verdict.But the code snippet above mentioned it does not.

Теги help, syntax, beginner

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Naaz 2023-06-24 10:28:36 687 Initial revision (published)