• 2022-06-01
    以下能正确定义函数的是( )。
    A: int fun(long n){ long a; ... return a; }
    B: long fun(int a){ long a; ... return a; }
    C: long fun(int n){ long a; ... return a; }
    D: long fun(long a){ long a; ... return a; }
  • C

    内容

    • 0

      Which five methods,inserted independently at line 5,will compile?() A: public int blipvert(int x){return 0;} B: private int blipvert(int x){return 0;} C: private int blipvert(long x){return 0;} D: protected int blipvert(long x){return 0;} E: protected long blipvert(long x){return 0;} F: protected long blipvert(int x, int y){return 0;}

    • 1

      Given: Which five methods, inserted independently at line 5, will compile?() A: public int blipvert(int x) { return 0; } B: private int blipvert(int x) { return 0; } C: private int blipvert(long x) { return 0; } D: protected long blipvert(int x) { return 0; } E: protected int blipvert(long x) { return 0; } F: protected long blipvert(long x) { return 0; }

    • 2

      读程序并写结果。#include stdio.hlong fun(int n){ long s;if(n==1||n==2)s=2;elses=n-fun(n-1);return s;}int main(){ printf(%ld\n,fun(3)); return 0;}

    • 3

      已知 int sum(int n){return n+n;} long sum(long n){return n+n;} 是一个函数模板的两个实例,则该函数模板的定义是__ ___ ___ 。

    • 4

      中国大学MOOC: 以下函数的功能是( )。long f(int n){ int i; long p; for(i=1;i<=n;i++) p=p*i; return p;}