请问return i == 1 ? i : i * getResult(i - 1);什么意思?public static int getResult(int i) {return i == 1 ? i : i * getResult(i - 1);}return i == 1 ? i : i * getResult(i - 1);求高手分析一下 ? :分别什么意思
来源:学生作业帮助网 编辑:作业帮 时间:2024/10/07 22:57:53
x){~RKJ2lm+ RHO- J-.)TU0Դ~Ύg-&d&+$ ̼d@^B5&Ʀg<~lބ';jPxgPijdW$SKxh;kCmlFJ\?Ovyi`$`#GBjNq*"-nEg>U/&=;IYgÓK Y-@u@mOyڻPHXQ2 ʴ/.H u#
请问return i == 1 ? i : i * getResult(i - 1);什么意思?public static int getResult(int i) {return i == 1 ? i : i * getResult(i - 1);}return i == 1 ? i : i * getResult(i - 1);求高手分析一下 ? :分别什么意思
请问return i == 1 ? i : i * getResult(i - 1);什么意思?
public static int getResult(int i) {
return i == 1 ? i : i * getResult(i - 1);
}
return i == 1 ? i : i * getResult(i - 1);
求高手分析一下 ? :分别什么意思
请问return i == 1 ? i : i * getResult(i - 1);什么意思?public static int getResult(int i) {return i == 1 ? i : i * getResult(i - 1);}return i == 1 ? i : i * getResult(i - 1);求高手分析一下 ? :分别什么意思
相当于
if(i==1)
{
return i;
}
else
{
return i*getresult(i-1);
}
这是一个递归,所以getResult(i)求的是i的阶导,即1*2*3*……*i