慕函数9227957
2017-02-08 14:26
我是这样写的
int one = 10 ;
int two = 20 ;
int three = 0 ;
three=one+two;
three+=one;
three-=one;
three*=one;
three/=one;
three%=one;
System.out.println("three%=one==>"+three);
System.out.println("three/=one==>"+three);
System.out.println("three*=one==>"+three);
System.out.println("three-=one==>"+three);
System.out.println("three+=one==>"+three);
System.out.println("three=one+two==>"+three);
我这样写的话里面的three就恒是0 是不是一定要按照给的答案那样编写three才不会一直为0啊
恳请解答一下!
程序执行时从上到下的,假如你执行一句,就输出结果,那么就对了,因为变量的值时变的,要及时输出
比如:
int one = 10 ;
int two = 20 ;
int three = 0 ;
three=one+two;
System.out.println("three%=one==>"+three);
three+=one;
System.out.println("three/=one==>"+three);
three-=one;
System.out.println("three*=one==>"+three);
three*=one;
System.out.println("three-=one==>"+three);
three/=one;
System.out.println("three+=one==>"+three);
three%=one;
System.out.println("three=one+two==>"+three);
这样就对了,
这个是我写的(参考):
System.out.println("three = one + two ==> "+(three = one + two));
System.out.println("three += one ==> "+(three += one));
System.out.println("three -= one ==> "+(three -= one));
System.out.println("three *= one ==> "+(three *= one));
System.out.println("three /= one ==> "+(three /= one));
System.out.println("three %= one ==> "+(three %= one));
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题