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

为啥我一个一个输出老是运行失败

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); 为什么我一个一个输出运行失败了

正在回答

4 回答

public class HelloWorld{
    public static void main(String[] args) {
     int one = 10 ;
        int two = 20 ;
        int three = 0 ;
        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));
 }
}

不用增加变量,直接输出。

0 回复 有任何疑惑可以回复我~

public class HelloWorld{

    public static void main(String[] args) {

    int one = 10 ;

        int two = 20 ;

        int three = 0 ;

         int a=three=one+two;

         int b=three+=one;

         int c=three-=one;

         int d=three*=one;

         int e=three/=one;

         int f=three%=one;

         

        System.out.println("three = one +two==>"+a);

        System.out.println("three +=one==>"+b);

        System.out.println("three -=one==>"+c);

        System.out.println("three  *=one==>"+d);

        System.out.println("three /=one==>"+e);

        System.out.println("three %=one==>"+f);


0 回复 有任何疑惑可以回复我~

 int one = 10 ;        int two = 20 ;        int three = 0         three=one+two;        int a=three+=one;        int b=three-=one;        int c=three*=one;        int d=three/=one;     int e=three%=one;                System.out.println("three=one+two ==>"+three);        System.out.println("three+=one ==>"+a);        System.out.println("three-=one ==>"+b);        System.out.println("three*=one ==>"+c);        System.out.println("three/=one ==>"+d);        System.out.println("three%=one ==>"+e);        }}

0 回复 有任何疑惑可以回复我~

要放在一起算  因为他每一次都运用了前一次的计算结果累计使用的,一次次的算每一次的数值都是初始的赋值  算起来当然不正确。

 int one = 10 ;        int two = 20 ;        int three = 0 ;         three=one+two;        int a=three+=one;        int b=three-=one;        int c=three*=one;        int d=three/=one;        int e=three%=one;         //你的所有System.out.println都错写为System.out.printlin了        System.out.println("three=one+two ==>"+three);    //题目里  ==>  是要打印的内容        System.out.println("three+=one ==>"+a);        System.out.println("three-=one ==>"+b);        System.out.println("three*=one ==>"+c);        System.out.println("three/=one ==>"+d);        System.out.println("three%=one ==>"+e);        }}


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为啥我一个一个输出老是运行失败

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