下列不是递归函数的是( )。
下列不是递归函数的是( )。
A.int t(int n)
{ if(n==0) return 0;
else return(n-1);
}
B.int t(int n)
{ if(n==0) return 0;
else return t(n-1);
}
C.int t(int n)
{ if(n==0) return 0;
else return n+t(n-1);
}
D.int t(int n)
{ if(n==0) return 1;
else return n*t(n-1);
}
A.int t(int n)
{ if(n==0) return 0;
else return(n-1);
}
B.int t(int n)
{ if(n==0) return 0;
else return t(n-1);
}
C.int t(int n)
{ if(n==0) return 0;
else return n+t(n-1);
}
D.int t(int n)
{ if(n==0) return 1;
else return n*t(n-1);
}
查看答案解析
【正确答案】
A 【答案解析】
只有A选项的else部分返回值时没有再次调用函数,所以答案选A。参见教材P175。 本题知识点:函数的嵌套调用和递归调用,
让自考更有氛围,想加入自考365交流群请添加小编微信zbzikao365
你可能喜欢