Как он может мне пригодиться? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
- 2

Как он может мне пригодиться?

Безусловно, что это достаточно интересные функции x++ и ++x, но где может пригодиться такое различие, ведь фактически можно написать y=x; x++; вместо y=++x; Всего лишь для сокращения кол-ва строк? Буду благодарен, если приведете примеры!

6th Jan 2017, 2:14 PM
Mark Yuplanov
Mark Yuplanov - avatar
1 ответ
+ 2
I would like to answer your question, but unfortunately I don't understand nor can read the language you wrote in. Looking at the keywords (++x, x++) I assume you'd like some explanation about the difference between these two operators. ++x first adds one to x and then executes the operator. x++ first executes the operator and adds one to x afterwards. Assume y=0 and x=5. The statement y=++x gives y=6 and x=6 The statement y=x++ gives y=5 and x=6 I hope this answers your question. If not, please post in English or German.
7th Jan 2017, 9:31 AM
rick schadron
rick schadron - avatar