第一:變量three在語(yǔ)句:int three = 0;已經(jīng)定義過(guò)了,后面就不需要重復(fù)定義了。
第二:再者而言,你的賦值語(yǔ)句也是錯(cuò)的,因?yàn)?=、-=等運(yùn)算符號(hào)兩邊都需要數(shù)值來(lái)進(jìn)行運(yùn)算。就拿這句來(lái)講把:int three += one;在這個(gè)語(yǔ)句中,變量one的值是明確的額,one的值是10,而你新定義的變量three卻沒(méi)有明確的值,你讓系統(tǒng)怎么算出答案?(在C++中,系統(tǒng)會(huì)為這個(gè)變量three賦任意值,運(yùn)算結(jié)果當(dāng)然不對(duì))
int one = 10;int two = 20;int three = 0;
three = one+two;System.out.println("three="+three);
three += one;System.out.println("three="+three);
three -= one;System.out.println("three="+three);
2017-01-22
第一:變量three在語(yǔ)句:int three = 0;已經(jīng)定義過(guò)了,后面就不需要重復(fù)定義了。
第二:再者而言,你的賦值語(yǔ)句也是錯(cuò)的,因?yàn)?=、-=等運(yùn)算符號(hào)兩邊都需要數(shù)值來(lái)進(jìn)行運(yùn)算。就拿這句來(lái)講把:int three += one;在這個(gè)語(yǔ)句中,變量one的值是明確的額,one的值是10,而你新定義的變量three卻沒(méi)有明確的值,你讓系統(tǒng)怎么算出答案?(在C++中,系統(tǒng)會(huì)為這個(gè)變量three賦任意值,運(yùn)算結(jié)果當(dāng)然不對(duì))
2017-01-22
漏寫(xiě);號(hào)