以下C++代码中存在几处错误( )。
#include <iostream>
using namespace std;
int main() {
const int SIZE = 5;
int arr[SIZE];
for (int i = 0; i <= SIZE; i++) {
arr[i] = i * 2;
}
cout << arr[SIZE] << endl;
return 0;
}
- A. 0处
- B. 1处
- C. 2处
- D. 3处
正确答案:C
#include <iostream>
using namespace std;
int main() {
const int SIZE = 5;
int arr[SIZE];
for (int i = 0; i <= SIZE; i++) {
arr[i] = i * 2;
}
cout << arr[SIZE] << endl;
return 0;
}
正确答案:C
想系统刷完 GESP C++ 1~8 级真题,并查看每道题的逐题精讲?
进入 GESPPASS 开始练习