• 2022-06-16
    下列语句中,哪个正确完成整形变量的声明和赋值
    A: int conut,count=0;
    B: int count=0;
    C: count=0;
    D: int count1=0,count2=1;
  • B,D

    举一反三

    内容

    • 0

      阅读以下程序public class Count{static int count;int number;public Count(){count = count + 1;number = count;}}class Test{public static void Main(){Count a = new Count();Count b = new Count();Count c = new Count();}}程序运行后,对象a的count值是() A: 0 B: 1 C: 2 D: 3

    • 1

      以下哪个方法是正确的? 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;}

    • 2

      下列哪条语句是正确的?_______________ A: int count = 5; int* x = &count; B: int count = 5; int x = &count; C: int count = 5; int& x = &count; D: int count = 5; int** x = &count;

    • 3

      代码中myCount.count的值为(A)?public class Test { public static void main(String[] args) { Count myCount = new Count(); int times = 0; for (int i=0; i<100; i++) increment(myCount, times); System.out.println("myCount.count = " + myCount.count); } public static void increment(Count c, int times) { c.count++; times++; }} class Count { int count; Count(int c) { count = c; } Count() { count = 1; }} A: 101 B: 100 C: 99 D: 98

    • 4

      下列程序中sumFun()的算法时间复杂度为 ( ) 。int sumFun(int n) { int count = 0; for (int i = 1; i < n; i = i * 2) for (int j = i; j > 0; j = j - 1) count = count + i + j; return count; } A: O(n) B: O(nlogn) C: O(n^2) D: O(logn logn)