Because the first fragment n++resolves to nbefore incrementing. So when you do this:
n = n++;
it saves n, then increments it, and then writes the saved value back to n.
In the second fragment, this assignment does not occur, therefore the increment "sticks".
Think of the following operations: the procedure from the innermost [ ]characters to the outermost:
[n = [[n]++]] [[n]++]
- current n (0) saved. - current n (0) saved.
- n incremented to 1. - n incremented to 1.
- saved n (0) written to n. - saved n (0) thrown away.
n, n = n + 1; n++;.