int mystery ( int number ) { if ( number <= 1 ) return 1; else return number * mystery( number – 1 ); }
举一反三
- 在划线处填写适当内容完成程序,本程序当输入字符是数字时输出字符串“number”,否则输出“none” #include int check_number(char x){ if ((x>='0')&&(x<='9')) return 1; else return 0; } int main(void){ char ch; while(1){ scanf("%c",&ch); if(ch=='#') break; if(__________) printf("number\n"); else printf("none\n"); } return 0; }
- 以下给数组赋值的语句正确的是() A: int[] number ; number = {1,2,3,4,5}; B: int[] number = {1,2,3,4,5}; C: int[] number = new int[5]; number[5] = 5; D: int[] number = new int[5]; number = 5;
- Analyze the following code: Code 1: int number = 45; bool even; if (number % 2 == 0) even = true; else even = false; Code 2: int number = 45; bool even = (number % 2 == 0); A: Code 1 has compile errors. B: Code 2 has compile errors. C: Both Code 1 and Code 2 have compile errors. D: Both Code 1 and Code 2 are correct, but Code 2 is better.
- 下列代码的输出结果是( )。function maxC(x: number, y?: number): number { if (y) { return x y ? x : y; } else { return x; }}console.log(maxC(3)); A: 运行错误 B: 运行正确,结果为1 C: 运行正确,结果为2 D: 运行正确,结果为3
- 下列表达式可以作为判断一个整数number为奇数的是() A: number // 2 == 1 B: number // 2 == 0 C: number % 2 == 1 D: number / 2 == 1