I've written a problem for an algorithm problem. I'm new to C++, and I'm getting the following error message when I try to run my code: "array initializer must be an initializer list". Here's the code itself:
#include <iostream>
#include <algorithm>
#include <array>
using namespace std;
int main(){
int n;
cin>>n;
int a[n][2];
int b[n];
for(int i=0;i<n;i++){
cin>>a[i][0];a[i][1]=i;
b[i]=a[i][0];
}
sort(a,a+n);
for(int i=1;i<n;i++)
{
if(a[i][0]<=a[i-1][0]){
a[i][0]=a[i-1][i]+1;
b[i]=a[i-1][i]+1;
}
}
for(int i=0;i<n;i++)
cout<<b[i]<<" ";
}
I don't know why I'm getting this error message. I've Googled it and couldn't find anything useful. If someone could explain to me why I'm getting this message and how to solve it, I'd really appreciate it. Thanks in advance.