慕粉4034683
2016-09-22 10:07
这个怎么输出呢?每个“three”都不一样的值,每次需要给赋值到一个变量中吗?如果不赋值最后要怎样才能把那几个数值全部输出呢?
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
three=one+two;
System.out.println(three);
three+=one;
System.out.println(three);
three-=one;
System.out.println(three);
three*=one;
System.out.println(three);
three/=one;
System.out.println(three);
three%=one;
System.out.println(three);
}
}
//每个“three”都不一样的值,每次需要给赋值到一个变量中吗?
//只有一个变量,名字叫所three。每次变化后输出即可!!!
public class Fanch {
public static void main(String[] args){
int one=10;
int two=20;
int three=0;
int t1=three=one+two;
int t2=three+=one;
int t3=three-=one;
int t4=three*=one;
int t5=three/=one;
int t6=three%=one;
System.out.println(t1);
System.out.println(t2);
System.out.println(t3);
System.out.println(t4);
System.out.println(t5);
System.out.println(t6);
我是这样的,也对的,但是觉得有点麻烦。还是一楼分别赋值输出好用
因为改变的就是three的值,one two是不变的,
写完一条运算,跟一条输出语句
three = one + two;
System.out.println("one + two="+three);
Java入门第一季(IDEA工具)升级版
1165550 学习 · 17586 问题
相似问题