#GESP202509C4T2. 判断题(每题 2 分,共 20 分)

判断题(每题 2 分,共 20 分)

  1. 以下代码能正确初始化指针。
int a = 5; 
int*p = a;

{{ select(16) }}

  • 正确
  • 错误
  1. 执行下面C++代码将输出 11 。
int x= 10; 
void f(){    
    int x= x+ 1;    
    cout<< x<< endl; 
}
int main(){    
    f(); 
}

{{ select(17) }}

  • 正确
  • 错误
  1. 以下C++代码合法。
struct Student{    
    string name;    
    int age;    
    float score; 
}; 
Student* students= new Student[20];

{{ select(18) }}

  • 正确
  • 错误
  1. 执行下面C++代码将输出 10 。
void func(int* p){    
    *p= 10; 
}
int main(){    
    int a= 5;    
    func(&a);    
    cout<< a<< endl;    
    return 0; 
}

{{ select(19) }}

  • 正确
  • 错误
  1. 下面代码将二维数组 arrarr 传递给函数 ff ,函数内部用 arr[i][j] 访问元素,函数参数声明为 int arr[][4] 是错误的。
void f(int arr[][4], int rows){    
    //访问 arr[i][j] 
}
int main(){    
    int arr[3][4]={/*初始化*/};    
    f(arr, 3); 
}

{{ select(20) }}

  • 正确
  • 错误
  1. 递推是在给定初始条件下,已知前一项(或前几项)求后一项的过程。

    {{ select(21) }}

  • 正确
  • 错误
  1. 虽然插入排序的时间复杂度为 O(n2)O(n^2) ,但由于单元操作相对较少,因此在小数据量的排序任务中非常受欢迎。

    {{ select(22) }}

  • 正确
  • 错误
  1. 对整数数组 {4, 1, 3, 1, 5, 2} 进行冒泡排序(将最大元素放到最后),执行一轮之后是 {4, 1, 3, 1, 2, 5}

    {{ select(23) }}

  • 正确
  • 错误
  1. 以下代码只能捕获 int 类型异常。
int main(){    
    try{        
        throw 42;
    } catch(...){
        cout<<"Caught"<< endl;   
    }    
    return 0; 
}

{{ select(24) }}

  • 正确
  • 错误
  1. 以下代码将 Hello 写入文件 data.txt
ofstream file("data.txt"); 
cout<<"Hello"<< endl; 
file.close();

{{ select(25) }}

  • 正确
  • 错误