I have two vectors of type string with default elements and an array of type integer that is filled with random numbers:
string vector1[5] = {"columna 1", "columna 2", "columna 3", "columna 4", "columna 5"};
string vector2[5] = {"fila 1", "fila 2", "fila 3", "fila 4", "fila 5"};
int matriz[5][5];
srand(time(NULL));
for( int i=0; i<5 ; i++)
{
for( int j=0; j<5; j++)
{
matriz[i][j]=1+rand()%(1000-1);
cout<<matriz[i][j]<<" ";
}
cout<<endl;
}
At the moment of executing it it looks very messy because the numbers are random, an order cannot be predicted.
I would like to be able to center the elements of the array but with an order relative to the elements of my vectors, Is there a way to do it with the printf function? I think it would be something like printf ("% 8d% 13d ... but I find it very confusing to understand that syntax with arrays and even worse with arrays. My idea is as shown like an Excel Table.
columna 1 columna 2 columna 3 columna 4 columna 5
fila 1 697 136 671 170 15
fila 2 637 9 382 758 133
fila 3 207 383 668 887 84
fila 4 796 751 566 236 334
fila 5 72 594 870 262 3