Problem1045--初识数组-数组越界问题

1045: 初识数组-数组越界问题

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1577  Solved: 1315
[Status] [Submit] [Creator:]

Description

在使用数组的时候,不能够使用未创建的数组,否则程序会报错。
int a[100]  表示创建100个盒子,a[0]~a[99],如果用超过范围的数组,就是数组越界


比如以下代码:

#include <bits/stdc++.h>

using namespace std;

int a[100];

int main() 

{

cout<<a[100000];

return 0;

}

这类问题被称为数组越界,而想要避免这个问题,只需要在使用数组的时候注意不要使用超过限度即可。
比如以下的代码就不会产生错误:

#include <bits/stdc++.h>

using namespace std;

int a[100];

int main() 

{

    cout<<a[10];

    return 0;

}

Input

Output

提交以上代码中不会越界的代码即可正确。

Sample Input Copy

Sample Output Copy

0

Source/Category

 入门