java 兔子编程题 求助

来源:百度知道 编辑:UC知道 时间:2024/06/23 15:31:34
一对兔子 3个月或每生1对,小兔子长到3个月又生1对,假如兔子不死,第10个月有多少对?
int m=1,n=1,tmpN//看不懂;
for(int month=3;month<=10;month++){
tmpN=n;//看不懂
n=m+n;//看不懂
m=tmpN;//看不懂
}
System.out.println(n);

for里面我看的懂,请问tmpN和tmpN=n; n=m+n;m=tmpN;是什么意思啊?

int m=1,n=1,tmpN;//声明3个变量(int类型的 )
for(int month=3;month<=10;month++){
tmpN=n;//让tmpN=n,也就是1
n=m+n;//然后让m和n相加,既n=1+1=2;
m=tmpN;//然后再把tmp的值1付给m,既m=2
} //继续循环
System.out.println(n);

你的基础太差了,多学学