what does x— or x++ do here?

后端 未结 7 1169
猫巷女王i
猫巷女王i 2021-01-23 01:53

it is a silly Q for most of u - i know - but i one of the beginner here, and I can not understand why the output in here are 12 what does this (x--) do to the resu

相关标签:
7条回答
  • 2021-01-23 02:53

    x++ increments x after x being evaluated. ++x increments x before x being evaluated.

     int x = 0;
     print(++x); // prints 1
     print(x); // prints 1
    
     int y = 0;
     print(y++); // prints 0
     print(y); // prints 1
    

    The same goes for --

    0 讨论(0)
提交回复
热议问题