不好意思,还想问学长几个问题
1。what is i after the following for loop?
for (int i=0;i<10;++i){
y+=i;
}
为什莫答案是undefined?不应该是10吗?
2。analyze the following fragment:
double sum=0;
double d=0;
while(d!=10.0){
d+=0.1;
sum+=sum+d;
}
答案:the program may not stop because of the phenomenon referred t as numerical inaccuracy for uperating with floating-pointing numbers.
为啥?不懂~~~~
3。analyze the following code:
boolean even=false;
if(even=true){
system.out.println(" it is even!");
}
写得有错吗?结果是什莫?
4。even=number%2==0
有这种写法么? 是什莫意思呢?计算机看到这个expression后又是怎样工作的?
多谢学长的帮助!!
for (int i=0;i<10;++i){
y+=i;
}
为什莫答案是undefined?不应该是10吗?
2。analyze the following fragment:
double sum=0;
double d=0;
while(d!=10.0){
d+=0.1;
sum+=sum+d;
}
答案:the program may not stop because of the phenomenon referred t as numerical inaccuracy for uperating with floating-pointing numbers.
为啥?不懂~~~~
3。analyze the following code:
boolean even=false;
if(even=true){
system.out.println(" it is even!");
}
写得有错吗?结果是什莫?
4。even=number%2==0
有这种写法么? 是什莫意思呢?计算机看到这个expression后又是怎样工作的?
多谢学长的帮助!!