为什么出现这种乱码呢


#include <iostream>
using namespace std;
int main()
{
    int a[10] = { 10,56,58,57,45,12,48,45,48,47 }, n, t,j;
    cout << "排序前的数组:" << endl;
    for (n = 0; n <= 10; n++)
    {
        cout << a[n] << "  ";
        if ((n + 1) % 5 == 0) cout << endl;
    }
    for (n = 1; n <= 10; n++)
    {
        for (j = 0; j <= 10 - n; j++)
        {
            if (a[j] < a[j + 1])
            {
                t = a[j]; a[j] = a[j + 1]; a[j + 1] = t;
            }
        }
    }
        cout << "排序后的数组:" << endl;
        for (n = 0; n < 10; n++)
        {
            cout << a[n] << "  ";
            if ((n + 1) % 5 == 0)cout << endl;
        }
    return 0;
}


![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/883180278336147.png "=600 #left")

数组越界了

img