第1讲-小测验
1、单选题:
以下各语言书写的代码可认为其功能是相同的。对于该代码,哪项判断是正确的?C/C++:#include <stdio.h>int hehe(){ printf("hehe"); hehe(); return 0;}int main(){ hehe(); return 0;}Java语言:public class Main{ public static int hehe() { System.out.println("hehe"); hehe(); return 0; } public static void main(String args[]) { hehe(); }}Python语言:def hehe(): print("hehe") hehe() return 0hehe()
选项:
A: 代码有错,无法运行。
B: 代码可以运行,并在有限次函数调用后结束。
C: 代码可以运行,将产生无限次函数递归调用(不考虑机器出故障、停电等意外因素)。
D: 以上都不对。
答案: 【 代码可以运行,并在有限次函数调用后结束。】点我阅读全文