• 2022-06-08
    以下哪个方法是正确的?
    A: public static int Sum(int n, params int[] val){ int count = 0; foreach (int a in val){ count = count + a; } return count + n;}
    B: public static int Sum(params int[] val, int n){ int count = 0; foreach (int a in val){ count = count + a; } return count + n;}
    C: public static int Sum(params int[] v1, params int[] v2){ int c1 = 0, c2 = 0; foreach (int a in v1){ c1 = c1 + a; } foreach (int a in v2){ c2 = c2 + a; } return c1 + c2;}
    D: public static int Sum(params int[] v, char ch){ int c = 0; foreach (int a in v){ c = c + a; } return c + ch;}
  • 举一反三