关于一维数组与二维数组的输入输出问题

关于一维数组与二维数组的输入输出问题
写了一个排序的代码但我发现了一个问题

#include <bits/stdc++.h>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
int maxn[100];
int n;
int c=0;
int a[100];
scanf("%d", &n);
for(int i=1;i<=n;i++){
scanf("%d", &a[i]);
}
for(int i=1;i<=n;i++){
maxn[i]=i;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n-1;j++){
if(a[maxn[j]]<a[maxn[j+1]]){
c=maxn[j];
maxn[j]=maxn[j+1];
maxn[j+1]=c;
}
for(int q=1;q<=n;q++){
cout<<a[maxn[q]]<<' ';
}
cout<<endl;
}
}
return 0;
}

上面的代码能正常输出但把啊a[x]换成a[1][x]后就输出不了

#include <bits/stdc++.h>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
int maxn[100];
int n;
int c=0;
int a[1][100];
scanf("%d", &n);
for(int i=1;i<=n;i++){
scanf("%d", &a[1][i]);
}
for(int i=1;i<=n;i++){
maxn[i]=i;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n-1;j++){
if(a[1][maxn[j]]<a[1][maxn[j+1]]){
c=maxn[j];
maxn[j]=maxn[j+1];
maxn[j+1]=c;
}
for(int q=1;q<=n;q++){
cout<<a[1][maxn[q]]<<' ';
}
cout<<endl;
}
}
return 0;
}

C中数组的下标是从0开始的

img

修改后的程序
#include <bits/stdc++.h>
using namespace std;


int main() {
int maxn[100];
int n;
int c=0;
int a[1][100];
scanf("%d", &n);
for(int i=1;i<=n;i++){
    scanf("%d", &a[0][i]);
}
for(int i=1;i<=n;i++){
    maxn[i]=i;
}
for(int i=1;i<=n;i++){
    for(int j=1;j<=n-1;j++){
        if(a[0][maxn[j]]<a[0][maxn[j+1]]){
            c=maxn[j];
            maxn[j]=maxn[j+1];
            maxn[j+1]=c;
        }
        for(int q=1;q<=n;q++){
            cout<<a[0][maxn[q]]<<' ';
        }
        cout<<endl;
    }
}
    return 0;
}

a[0][]


int a[1][100];

该数组定义一个一行100列的矩阵,在C语言中,数组下标从0开始,所以第一行的下标为0,即a[0][i],表示第一行,a[1][i]表示第二行,a只有一行,所以a[1][i]会造成数组越界