---
# System prepended metadata

title: Some Tips of Extra/EZtra problems (2)
tags: [112計概]

---

## Why am I getting a RE?
In most Online Judges, RE stands for "Runtime Error". Basically, as long as the code is compiled successfully and does not time out or excessively use space, RE will be displayed if any errors occur during execution that cause the program to fail to execute normally.

The more common situations occur in the following:

### Out-of-bounds index
```C++
    int arr[2];
    // Accessing out of bound
    arr[3] = 10;
```

```C++
    char s[3] = {"SUNGOD"};
```

### Improper use of scanf
```C++
    int n = 2;
    scanf("%d", n);
```

### Stack Overfloｗ
```C++
    long long int arr[2000000000];
    // Sometimes MLE
```

### NULL Pointer
```C++
    int* nptr = NULL;
    printf("%d", *nptr);
```

### Division by zero
    as literally


### Unvoid-function without return value

```C++
    int isbig(int x,int y){
        if(x>y)return 1;
        //else?
    }
```


---

## How to avoid RE?

As you can see, there are many possibilities for RE. The above cannot even list half of all examples, and sometimes the code of RE does not show it because in fact many behaviors that cause RE are undefined. Different Compilers may perform various processings. Taking "Division by zero" as an example, some OJ will use 0 as the operation result.

A better solution is to accumulate more coding experience. The more you write, the fewer mistakes you make.

Of course, some small tools that help with coding may also be helpful (such as ChatGPT), but I don't recommend relying too much on them. In other words, I might take the code with bugs that I have written and ask it what the mistake is, rather than ask it to generate a whole Code.