+ 1
how result becomes 7 ?,please explain
3 Réponses
+ 1
x-=-(++x)-x
For example if x=5
The new value of x will be:
X-=-(6)-5 // (6) because of (++x)
x-=-6-5
x-=-11
X-= means that whatever value is on the left side of = will be subtracted from the value of x, the answer will be the new value of x:
x=x-(-11)
X=5-(-11)
X=16
+ 2
public class Program
{
public static void main(String[] args) {
int x = 0;
for(x=1;x<10;x++)
{
if(x==6)
{
System.out.print(++x);
}
if(x==9)
{
System.out.print(x--);
}
x -=-(++x)-x;
}
}
}
When x is equal to 6, the condition (if (x==6)) becomes true and it's executed. Instead of printing 6, the value of x (6) is first incremented by 1 because of (++x)...
+ 2
I can not understand x-=-(++x)-x