Language: C++

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

double read[1100];
vector<int> re;
void init(int d){
    int tot=d+3;
    re.clear();
    for(int i=0;i<(1<<tot);i++){
        int tmp=0;
        for(int j=0;j<tot;j++){
            if((i>>j)&1)tmp++;
        }
        if(1+d==tmp){
            re.push_back(i);
        }
    }
}

double a[10][10],x[10];
const double eps=1e-5;
inline int sgn(double x)
{
    return fabs(x)<eps?0:(x>0.0?1:-1);
}
int Gauss(int equ,int var)
{
    int i,j,k,col,max_r;
    for(k = 0,col = 0;k < equ && col < var;k++,col++)
    {
        max_r = k;
        for(i = k+1;i < equ;i++)
            if(fabs(a[i][col]) > fabs(a[max_r][col]))
                max_r = i;
        if(fabs(a[max_r][col]) < eps)return 0;
        if(k != max_r)
        {
            for(j = col;j < var;j++)
                swap(a[k][j],a[max_r][j]);
            swap(x[k],x[max_r]);
        }
        x[k]/=a[k][col];
        for(j = col+1;j < var;j++)a[k][j]/=a[k][col];
        a[k][col] = 1;
        for(int i = 0;i < equ;i++)
            if(i != k)
            {
                x[i] -=  x[k]*a[i][k];
                for(j = col+1;j < var;j++)a[i][j] -= a[k][j]*a[i][col];
                a[i][col] = 0;
            }
    }
    return 1;
}

int check(int num,int d){
    memset(a,0,sizeof(a));
    memset(x,0,sizeof(x));
    int totbit=d+3;
    int nowline=0;
    for(int i=0;i<totbit;i++){
        if((num>>i)&1){
            for(int j=0;j<d+1;j++){
                double y=1;
                for(int k=0;k<j;k++){
                    y*=i;
                }
                a[nowline][j]=y;
            }
            x[nowline]=read[i];
            nowline++;
        }
    }
    int ret=Gauss(nowline,nowline);
    if(0==ret)return -1;
    int cc=0;
    int idx=-1;
    for(int i=0;i<totbit;i++){
        double y=0;
        for(int j=0;j<d+1;j++){
            double z=1;
            for(int k=0;k<j;k++){
                z*=i;
            }
            z*=x[j];
            y+=z;
        }
        y-=read[i];
        if(0==sgn(y))cc++;
        else idx=i;
    }
    if(cc==d+2)return idx;
    return -1;
}

int main(){
    int d;
    while(scanf("%d",&d)&&d){
        for(int i=0;i<d+3;i++){
            scanf("%lf",&read[i]);
        }
        init(d);
        for(int i=0;i<re.size();i++){
            int ret=check(re[i],d);
            if(ret!=-1){
                printf("%d\n",ret);
                break;
            }
        }
    }
    return 0;
}

Compiler output:
a.cc:4:17: error: 'double read [1100]' redeclared as different kind of entity
    4 | double read[1100];
      |                 ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:371:16: note: previous declaration 'ssize_t read(int, void*, size_t)'
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
a.cc: In function 'int check(int, int)':
a.cc:70:30: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   70 |             x[nowline]=read[i];
      |                              ^
a.cc:70:30: error: cannot convert 'ssize_t(int, void*, size_t)' {aka 'long int(int, void*, long unsigned int)'} to 'double' in assignment
   70 |             x[nowline]=read[i];
      |                        ~~~~~~^
      |                              |
      |                              ssize_t(int, void*, size_t) {aka long int(int, void*, long unsigned int)}
a.cc:88:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   88 |         y-=read[i];
      |                  ^
a.cc:88:10: error: invalid operands of types 'double' and 'ssize_t (*)(int, void*, size_t)' {aka 'long int (*)(int, void*, long unsigned int)'} to binary 'operator-'
   88 |         y-=read[i];
      |         ~^~~~~~~~~
a.cc:88:10: note:   in evaluation of 'operator-=(double, ssize_t (*)(int, void*, size_t) {aka long int (*)(int, void*, long unsigned int)})'
a.cc: In function 'int main()':
a.cc:100:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  100 |             scanf("%lf",&read[i]);
      |                                ^