This is my code:
#include <iostream>
using namespace std;
struct nodos
{
string nombre; //Nombre del nodo
string vecinos[]; //Los otros nodos del grafo
float aristas[]; //Valores de las aristas
};
int main()
{
int numnodos;
cout<<"Ingrese la cantidad de nodos a trabajar: ";
cin>>numnodos;
cout<<"\n";
nodos arreglodenodos[numnodos]; //Declaro un arreglo de estructuras
return 0;
}
I am making a program on graphs but when I wanted to program the nodes (vertices) I have run into the following problem:
- For example, enter 5 in the number of nodes to work.
So the structure array will now have a size of 5.
but here comes my problem
Obviously the number of neighbors will be
numnodos-1
- But I don't know how to assign that size to the array
vecinos[]
also witharistas[]
PS: as a bonus question. Would it be better to declare nodes as a class
or leave it as a struct
?