为了账号安全,请及时绑定邮箱和手机立即绑定

对码输出的结果有些不解

        int one = 10 ;

        int two = 20 ;

        int three = 0 ;

        three = one + two;

        System.out.println("three = one + two ==>"+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 ==>"+three);

输出的结果为:

three = one + two ==>30
three += one ==>40
three -= one ==>30
three *= one ==>300
three /= one ==>30
three %= one ==>0

倒数第二个结果不应该是3吗?three/=one不就是三十除十的结果吗?怎么是30呢?还有为什么每个输出的结果都是大于输出的值呢?

正在回答

1 回答

three = one + two; //此时three=10+20=30

three += one;//此时three=30+10=40

three -= one;//此时three=40-10=30

three *= one;//此时three=30*10=300

three /= one;//此时three=300/10=30

three %= one;此时three=30/10的余数0

1 回复 有任何疑惑可以回复我~
#1

时代风云 提问者

非常谢谢你的解释。
2016-10-12 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

对码输出的结果有些不解

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信