0

ok i have a problem, like you can see in the code i already create a bidimesional array step by step..... ok i want to eliminate that, and instead of that i want to load the array from a .txt like this>

0-0-6-0-0-0-6-0-0-0

0-0-8-4-0-0-0-0-0-0

6-8-0-0-0-0-0-0-0-0

0-4-0-0-2-0-0-0-0-0

0-0-0-2-0-4-0-0-0-0

0-0-0-0-4-0-0-1-0-0

6-0-0-0-0-0-0-0-0-5

0-0-0-0-0-1-0-0-7-0

0-0-0-0-0-0-0-7-0-0

0-0-0-0-0-0-5-0-0-0

and i want to insert the numbers in the bidimensional array one by one

how can i do that????

i tried using getline and strtok, but i don't know how to do it

sorry if my english isn't the best. i'm from costa rica

```
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
#include <iostream>
#include <fstream>
using namespace std;
void Floyd()
{
int n = 10;
int C[n][n];
C[0][0]=0;C[0][1]=0;C[0][2]=6;C[0][3]=0;C[0][4]=0;C[0][5]=0;C[0][6]=6;C[0][7]=0;
C[0][8]=0;C[0][9]=0;
C[1][0]=0;C[1][1]=0;C[1][2]=8;C[1][3]=4;C[1][4]=0;C[1][5]=0;C[1][6]=0;C[1][7]=0;
C[1][8]=0;C[1][9]=0;
C[2][0]=6;C[2][1]=8;C[2][2]=0;C[2][3]=0;C[2][4]=0;C[2][5]=0;C[2][6]=0;C[2][7]=0;
C[2][8]=0;C[2][9]=0;
C[3][0]=0;C[3][1]=4;C[3][2]=0;C[3][3]=0;C[3][4]=2;C[3][5]=0;C[3][6]=0;C[3][7]=0;
C[3][8]=0;C[3][9]=0;
C[4][0]=0;C[4][1]=0;C[4][2]=0;C[4][3]=2;C[4][4]=0;C[4][5]=4;C[4][6]=0;C[4][7]=0;
C[4][8]=0;C[4][9]=0;
C[5][0]=0;C[5][1]=0;C[5][2]=0;C[5][3]=0;C[5][4]=4;C[5][5]=0;C[5][6]=0;C[5][7]=1;
C[5][8]=0;C[5][9]=0;
C[6][0]=6;C[6][1]=0;C[6][2]=0;C[6][3]=0;C[6][4]=0;C[6][5]=0;C[6][6]=0;C[6][7]=0;
C[6][8]=0;C[6][9]=5;
C[7][0]=0;C[7][1]=0;C[7][2]=0;C[7][3]=0;C[7][4]=0;C[7][5]=1;C[7][6]=0;C[7][7]=0;
C[7][8]=7;C[7][9]=0;
C[8][0]=0;C[8][1]=0;C[8][2]=0;C[8][3]=0;C[8][4]=0;C[8][5]=0;C[8][6]=0;C[8][7]=7;
C[8][8]=0;C[8][9]=0;
C[9][0]=0;C[9][1]=0;C[9][2]=0;C[9][3]=0;C[9][4]=0;C[9][5]=0;C[9][6]=5;C[9][7]=0;
C[9][8]=0;C[9][9]=0;
int A [n][n];
string s [n][n];
printf("Inicial Matrix\n");
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
printf("%d ",C[i][j]);
}
printf("\n");
}
int i,j,k;
for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
{
if (C[i][j]==0)
{
A[i][j] = 999999999; // infinity
}
else
{
A[i][j] = 1;
char sz[3]="";
sprintf(sz,"%d",j+1);
s[i][j] = sz;
}
}
}
// set diagonal in zero
for (i=0; i<n; i++)
{
A[i][i] = 0;
}
for (k=0; k<n; k++)
{
for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
{
if ( A[i][k] + A[k][j] < A[i][j] )
{
A[i][j] = A[i][k]+ A[k][j];
s[i][j] = s[i][k]+ "," + s[k][j];
}
}
}
}
printf("\nShortest Distances\n");
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
printf("%d ",A[i][j]);
}
printf("\n");
}
printf("\nShortest paths:\n");
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
printf("Path to %d from %d is %s\n",i+1,j+1,s[i][j].c_str());
}
printf("\n");
}
}
int main()
{
Floyd();
system ("pause");
return 0;
}
```

Thanks