I need to code TSP problem using c++, but after finished my code, i got an error. Even after Google, I cannot figure it

-->> this is thee error code

#include <bits/stdc++.h>
using namespace std;
const long N = 10;

// final_path[] stores the final solution ie, the
// path of the salesman.
long final_path[N+1];

// visited[] keeps track of the already visited nodes
// in a particular path
bool visited[N];

// Stores the final minimum weight of shortest tour.
long final_res = LONG_MAX;

// Function to copy temporary solution to
// the final solution
void copyToFinal(long curr_path[])
{
	for (long i=0; i<N; i++)
		final_path[i] = curr_path[i];
	final_path[N] = curr_path[0];
}

// Function to find the minimum edge cost
// having an end at the vertex i
long firstMin(long double adj[N][N], long i)
{
	long min = LONG_MAX;
	for (long k=0; k<N; k++)
		if (adj[i][k]<min && i != k)
			min = adj[i][k];
	return min;
}

// function to find the second minimum edge cost
// having an end at the vertex i
long secondMin(long double adj[N][N], long i)
{
	long first = LONG_MAX, second = LONG_MAX;
	for (long j=0; j<N; j++)
	{
		if (i == j)
			continue;

		if (adj[i][j] <= first)
		{
			second = first;
			first = adj[i][j];
		}
		else if (adj[i][j] <= second &&
				adj[i][j] != first)
			second = adj[i][j];
	}
	return second;
}

// function that takes as arguments:
// curr_bound -> lower bound of the root node
// curr_weight-> stores the weight of the path so far
// level-> current level while moving in the search
//		 space tree
// curr_path[ ] -> where the solution is being stored which
//			 would later be copied to final_path[ ]

void TSPRec(long double adj[N][N], long curr_bound, long curr_weight,
			long level, long curr_path[])
{
	// base case is when we have reached level N which
	// means we have covered all the nodes once
	if (level==N)
	{
		// check if there is an edge from last vertex in
		// path back to the first vertex
		if (adj[curr_path[level-1]][curr_path[0]] != 0)
		{
			// curr_res has the total weight of the
			// solution we got
			long curr_res = curr_weight +
					adj[curr_path[level-1]][curr_path[0]];

			// Update final result and final path if
			// current result is better.
			if (curr_res < final_res)
			{
				copyToFinal(curr_path);
				final_res = curr_res;
			}
		}
		return;
	}

	// for any other level iterate for all vertices to
	// build the search space tree recursively
	for (long i=0; i<N; i++)
	{
		// Consider next vertex if it is not same (diagonal
		// entry in adjacency matrix and not visited
		// already)
		if (adj[curr_path[level-1]][i] != 0 &&
			visited[i] == false)
		{
			long temp = curr_bound;
			curr_weight += adj[curr_path[level-1]][i];

			// different computation of curr_bound for
			// level 2 from the other levels
			if (level==1)
			curr_bound -= ((firstMin(adj, curr_path[level-1]) +
							firstMin(adj, i))/2);
			else
			curr_bound -= ((secondMin(adj, curr_path[level-1]) +
							firstMin(adj, i))/2);

			// curr_bound + curr_weight is the actual lower bound
			// for the node that we have arrived on
			// If current lower bound < final_res, we need to explore
			// the node further
			if (curr_bound + curr_weight < final_res)
			{
				curr_path[level] = i;
				visited[i] = true;

				// call TSPRec for the next level
				TSPRec(adj, curr_bound, curr_weight, level+1,
					curr_path);
			}

			// Else we have to prune the node by resetting
			// all changes to curr_weight and curr_bound
			curr_weight -= adj[curr_path[level-1]][i];
			curr_bound = temp;

			// Also reset the visited array
			memset(visited, false, sizeof(visited));
			for (long j=0; j<=level-1; j++)
				visited[curr_path[j]] = true;
		}
	}
}

// This function sets up final_path[]
void TSP(long double adj[N][N])
{
	long curr_path[N+1];

	// Calculate initial lower bound for the root node
	// using the formula 1/2 * (sum of first min +
	// second min) for all edges.
	// Also initialize the curr_path and visited array
	long curr_bound = 0;
	memset(curr_path, -1, sizeof(curr_path));
	memset(visited, 0, sizeof(curr_path));

	// Compute initial bound
	for (long i=0; i<N; i++)
		curr_bound += (firstMin(adj, i) +
					secondMin(adj, i));

	// Rounding off the lower bound to an integer
	curr_bound = (curr_bound&1)? curr_bound/2 + 1 :
								curr_bound/2;

	// We start at vertex 1 so the first vertex
	// in curr_path[] is 0
	visited[0] = true;
	curr_path[0] = 0;

	// Call to TSPRec for curr_weight equal to
	// 0 and level 1
	TSPRec(adj, curr_bound, 0, 1, curr_path);
}

// Driver code
int main()
{
	//Adjacency matrix for the given graph
	long double adj[N][N] = { 
	    {0, 5.1, 12.5, 13.0, 7.5, 13.5, 0, 0, 24.1, 0},
	    
		{5.1, 0, 7.2, 9.2, 0, 0, 0, 0, 0, 0},
		
		{12.5, 7.2, 0, 8.0, 0, 0, 0, 21.5, 0, 33,2},
		
		{13.0, 9.2, 8.0, 0, 8.5, 0, 15.5, 14.1, 0, 0},
		
		{7.5, 0, 0, 8.5, 0, 11.5, 10.5, 17.3, 0, 0},
		
		{13.5, 0, 0, 0, 11.5, 0, 11.2, 0, 11.1, 0},
		
		{0, 0, 0, 15.5, 10.5, 11.2, 0, 8.9, 13.8, 12.7},
		
		{0, 0, 21.5, 14.1, 17.3, 0, 8.9, 0, 0, 8.5},
		
		{24.1, 0, 0, 0, 0, 11.1, 13.8, 0, 0, 12.1},
		
		{0, 0, 33.2, 0, 0, 0, 12.7, 8.5, 12.1, 0}};

	TSP(adj);

	printf("Minimum cost : %ld\n", final_res);
	printf("Path Taken : ");
	for (long i=0; i<N; i++)
		printf("%ld ", final_path[i]);

	return 0;
}

and this is the error message
main.cpp:198:44: error: too many initializers for ‘long double [10]’
198 | {0, 0, 33.2, 0, 0, 0, 12.7, 8.5, 12.1, 0}};
| ^

--->> and this is the error message
image

edit: i already updated the full coding

The error message could not be much clearer.

(Apart from posting the error message, and NOT a picture of it)

Your code is incomplete, and missing code tags.

for (long i=0; i<=N

Often leads to problems.

Starting with zero, <=N means N+1 elements or iterations. If N is 10 then it should be < N, so that there are 10 elements 0...9, inclusive of 0.

If your array has 10 elements then they are indexed starting with 0 till 9. N+1 makes it 10 - an index which does not exist in the array.

N+1 would mean 11 elements or iterations, 0..10

I think you meant "33.2" and not "33,2". That's trying to put 11 elements in a 10-element row.

COMPILER WARNING:
memset(visited, 0, sizeof(curr_path));
This is writing 44 bytes (sizeof(curr_path)) into 'visited' which is 10 bytes long! Change that to
memset(visited, 0, sizeof(visited));

Here is your code, modified to run on an Arduino UNO. It produces the output:

Starting setup()
Calling TSP()
Returned from TSP()
Minimum cost: 80
Path Taken : 0 5 8 9 7 6 4 3 2 1 

NOTE: After changing from "long double" to "float" and from "long" to "int" it gives the same answer in 59 milliseconds instead of 1.3 seconds: 22 times as fast.

// #include <bits/stdc++.h>
using namespace std;
const long N = 10;
const long LONG_MAX = 0x7FFFFFFF;

// final_path[] stores the final solution ie, the
// path of the salesman.
long final_path[N + 1];

// visited[] keeps track of the already visited nodes
// in a particular path
bool visited[N];

// Stores the final minimum weight of shortest tour.
long final_res = LONG_MAX;

// Function to copy temporary solution to
// the final solution
void copyToFinal(long curr_path[])
{
  for (long i = 0; i < N; i++)
    final_path[i] = curr_path[i];
  final_path[N] = curr_path[0];
}

// Function to find the minimum edge cost
// having an end at the vertex i
long firstMin(long double adj[N][N], long i)
{
  long min = LONG_MAX;
  for (long k = 0; k < N; k++)
    if (adj[i][k] < min && i != k)
      min = adj[i][k];
  return min;
}

// function to find the second minimum edge cost
// having an end at the vertex i
long secondMin(long double adj[N][N], long i)
{
  long first = LONG_MAX;
  long second = LONG_MAX;
  for (long j = 0; j < N; j++)
  {
    if (i == j)
      continue;

    if (adj[i][j] <= first)
    {
      second = first;
      first = adj[i][j];
    }
    else if (adj[i][j] <= second &&
             adj[i][j] != first)
      second = adj[i][j];
  }
  return second;
}

// function that takes as arguments:
// curr_bound -> lower bound of the root node
// curr_weight-> stores the weight of the path so far
// level-> current level while moving in the search
//     space tree
// curr_path[ ] -> where the solution is being stored which
//       would later be copied to final_path[ ]

void TSPRec(long double adj[N][N], long curr_bound, long curr_weight,
            long level, long curr_path[])
{
  // base case is when we have reached level N which
  // means we have covered all the nodes once
  if (level == N)
  {
    // check if there is an edge from last vertex in
    // path back to the first vertex
    if (adj[curr_path[level - 1]][curr_path[0]] != 0)
    {
      // curr_res has the total weight of the
      // solution we got
      long curr_res = curr_weight +
                      adj[curr_path[level - 1]][curr_path[0]];

      // Update final result and final path if
      // current result is better.
      if (curr_res < final_res)
      {
        copyToFinal(curr_path);
        final_res = curr_res;
      }
    }
    return;
  }

  // for any other level iterate for all vertices to
  // build the search space tree recursively
  for (long i = 0; i < N; i++)
  {
    // Consider next vertex if it is not same (diagonal
    // entry in adjacency matrix and not visited
    // already)
    if (adj[curr_path[level - 1]][i] != 0 &&
        visited[i] == false)
    {
      long temp = curr_bound;
      curr_weight += adj[curr_path[level - 1]][i];

      // different computation of curr_bound for
      // level 2 from the other levels
      if (level == 1)
        curr_bound -= ((firstMin(adj, curr_path[level - 1]) +
                        firstMin(adj, i)) / 2);
      else
        curr_bound -= ((secondMin(adj, curr_path[level - 1]) +
                        firstMin(adj, i)) / 2);

      // curr_bound + curr_weight is the actual lower bound
      // for the node that we have arrived on
      // If current lower bound < final_res, we need to explore
      // the node further
      if (curr_bound + curr_weight < final_res)
      {
        curr_path[level] = i;
        visited[i] = true;

        // call TSPRec for the next level
        TSPRec(adj, curr_bound, curr_weight, level + 1,
               curr_path);
      }

      // Else we have to prune the node by resetting
      // all changes to curr_weight and curr_bound
      curr_weight -= adj[curr_path[level - 1]][i];
      curr_bound = temp;

      // Also reset the visited array
      memset(visited, false, sizeof(visited));
      for (long j = 0; j <= level - 1; j++)
        visited[curr_path[j]] = true;
    }
  }
}

// This function sets up final_path[]
void TSP(long double adj[N][N])
{
  long curr_path[N + 1];

  // Calculate initial lower bound for the root node
  // using the formula 1/2 * (sum of first min +
  // second min) for all edges.
  // Also initialize the curr_path and visited array
  long curr_bound = 0;
  memset(curr_path, -1l, sizeof(curr_path));
  memset(visited, 0, sizeof(visited));

  // Compute initial bound
  for (long i = 0; i < N; i++)
    curr_bound += (firstMin(adj, i) +
                   secondMin(adj, i));

  // Rounding off the lower bound to an integer
  curr_bound = (curr_bound & 1) ? curr_bound / 2 + 1 :
               curr_bound / 2;

  // We start at vertex 1 so the first vertex
  // in curr_path[] is 0
  visited[0] = true;
  curr_path[0] = 0;

  // Call to TSPRec for curr_weight equal to
  // 0 and level 1
  TSPRec(adj, curr_bound, 0, 1, curr_path);
}

// Driver code
void setup()
{
  Serial.begin(115200);
  delay(200);
  Serial.println("Starting setup()");

  //Adjacency matrix for the given graph
  long double adj[N][N] =
  {
    {   0, 5.1, 12.5, 13.0,  7.5, 13.5,    0,    0, 24.1,    0},
    { 5.1,   0,  7.2,  9.2,    0,    0,    0,    0,    0,    0},
    {12.5, 7.2,    0,  8.0,    0,    0,    0, 21.5,    0, 33.2},
    {13.0, 9.2,  8.0,    0,  8.5,    0, 15.5, 14.1,    0,    0},
    { 7.5,   0,    0,  8.5,    0, 11.5, 10.5, 17.3,    0,    0},
    {13.5,   0,    0,    0, 11.5,    0, 11.2,    0, 11.1,    0},
    {   0,   0,    0, 15.5, 10.5, 11.2,    0,  8.9, 13.8, 12.7},
    {   0,   0, 21.5, 14.1, 17.3,    0,  8.9,    0,    0,  8.5},
    {24.1,   0,    0,    0,    0, 11.1, 13.8,    0,    0, 12.1},
    {   0,   0, 33.2,    0,    0,    0, 12.7,  8.5, 12.1,    0}
  };

  Serial.println("Calling TSP()");
  Serial.flush();
  TSP(adj);
  Serial.println("Returned from TSP()");
  Serial.flush();

  Serial.print("Minimum cost: ");
  Serial.println(final_res);
  Serial.flush();

  Serial.print("Path Taken : ");
  for (long i = 0; i < N; i++)
  {
    Serial.print(final_path[i]);
    Serial.print(' ');
  }
  Serial.println();
  Serial.flush();

}

void loop() {}