Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;

const double eps = 1e-8;
const int maxn = 100 + 10;
typedef double Matrix[maxn][maxn];

// 逕ア莠取悽鬚倡噪迚ケ谿頑??梧カ亥?蜷惹ク堺ク?ョ壽弍蟇ケ隗帝亰?檎爆閾ウ荳堺ク?ョ壽弍髦カ譴ッ髦オ
// 菴?凶x[i]隗」諠滉ク?ク疲怏髯撰シ檎ャャi陦碁勁莠?[i][i]蜥窟[i][n]荵句、也噪蜈カ莉門?邏?插荳コ0
void gauss_jordan(Matrix A, int n)
{
    int i, j, k, r;
    for(i = 0; i < n; i++)
    {
        r = i;
        for(j = i+1; j < n; j++)
            if (fabs(A[j][i]) > fabs(A[r][i])) r = j;
        if(fabs(A[r][i]) < eps) continue; // 謾セ蠑?ソ吩ク?。鯉シ檎峩謗・螟?炊荳倶ク?。?(*)
        if(r != i) for(j = 0; j <= n; j++) swap(A[r][j], A[i][j]);

        // 荳朱勁莠?ャャi陦悟、也噪蜈カ莉冶。瑚ソ幄。梧カ亥?
        for(k = 0; k < n; k++) if(k != i)
                for(j = n; j >= i; j--) A[k][j] -= A[k][i]/A[i][i] * A[i][j];
    }
}

Matrix A;
int n;
double v[maxn];
int d;
vector<int> prev[maxn];
int inf[maxn];

int main()
{
    //freopen("input.txt","r",stdin);
    while(scanf("%d", &d) == 1 && d)
    {

        for(int i=0; i<=d+2; i++)
            scanf("%lf",&v[i]);
        //for(int i=0;i<d+2;i++)
        //  cout << v[i] << " ";
        //cout <<endl;
        int found = 0;
        int ans = -1;
        for(int de = 0; de<=d+2; de++)
        {
            if(found)break;
            int kk;
            int cnt = 0;
            for(kk=0; kk<=d+2; kk++)
            {
                if(kk==de)continue;
                for(int i=0; i<=d; i++)
                    A[cnt][i] = pow((double)kk,(double)i);
                A[cnt][d+1] = v[kk];
                cnt++;
                if(cnt == d+1)break;
            }
            n = d+1;
            // for(int i=0;i<n;i++)
            // {
            //     for(int j=0;j<=n;j++)
            //         cout << A[i][j]  <<' ';
            //     cout <<endl;
            // }
            // 隗」譁ケ遞狗サ?シ梧?隶ー譌?ゥキ蜿倬?
            gauss_jordan(A, n);
            memset(inf, 0, sizeof(inf));
            for(int i = n-1; i >= 0; i--)
            {
                if(fabs(A[i][i])<eps && fabs(A[i][n])>eps) inf[i] = 1; // 逶エ謗・隗」蜃コ譚・逧?裏遨キ蜿倬?
                for(int j = i+1; j < n; j++)
                    if(fabs(A[i][j])>eps && inf[j]) inf[i] = 1; // 蜥梧裏遨キ蜿倬?謇ッ荳雁?邉サ逧?序驥丈ケ滓弍譌?ゥキ逧?            }
            double aa[10];
            int flag = 0;
            for(int i=0; i<n; i++)
                if(inf[i])
                {
                    flag = 1;
                    break;
                }
                else aa[i] = fabs(A[i][i])<eps ? 0.0 : A[i][n]/A[i][i];
            if(flag)continue;

            kk++;
            if(kk == de)kk++;
            double ans1 = 0,ans2 = 0;
            for(int i=0; i<n; i++)
            {
                ans1 += aa[i]*pow(kk,i);
                ans2 += aa[i]*pow(de,i);
            }
            if(fabs(ans1 - v[kk]) <= 0.001 && fabs(ans2 - v[de]) > 0.1)
            {
                ans = de;
                found = 1;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:109:2: error: expected '}' at end of input
  109 | }
      |  ^
a.cc:40:1: note: to match this '{'
   40 | {
      | ^