hello, good, it happens that I am making a program in c++ and I have to print the goals of each respective team, but in each row I have to concatenate each team, but I don't know how to do it, at least I am trying like this, since they all come together but the teams I must put them in each row, then in row 0 of the matrix is honduras, in row 1 el salvador, in row 2 the next and so on.
int aux;
cout<<"========================================================================\n";
cout<<" TABLA ESTADISTICA \n";
cout<<"========================================================================\n";
cout<<"SELECCIONES PJ PG PE PP GF GC DIF PTS \n";
//Imprimir equipos.
for(int i=0; i<4; i++)
{
cout<<nombre1<<"";
cout<<nombre2<<"";
cout<<nombre3<<"";
cout<<nombre4<<"";
for(int j=0; j<8; j++)
{
cout<<matriz[i][j]<<" ";
}
cout<<" \n";
}
cout<<"\n";
system("pause");
system("cls");
imprimirMenu();
It should technically display like this
Team names "duplicate" because you print
nombre1
,nombre2
,nombre3
andnombre4
on each iteration.You have to print only one.
You can do it like this:
You can see that it is difficult to work with and it would get worse if you had more equipment. A better way to do this is with an array, for example:
Or taking advantage of the class
string
:Even if you want to add more items, you can use a collection like
vector
:And print only the corresponding name with
nombres[i]
: