I'm making an adjacency list to represent a graph of roads, there are two kinds of weights (length and capacity) and for some reason this code never exits the for loop. it gets stuck on the cin for the last line. input is in the form:
4 5 4
0 1 1 5
0 2 1 4
1 2 2 2
1 3 1 4
2 3 1 5
I'm a student starting out. Help is very much appreciated thank you.
#include <iostream>
#include <vector>
using namespace std;
int N, M, T; //#cities N, #highways M, time available T
struct Road {
int Y, L, C; //destination Y, length L and capacity C
};
void readNetwork(vector<vector<Road>> &adjList) {
cin >> N >> M >> T;
adjList.resize(N);
for (int i = 0; i < M; i++){
int x, y, l, c;
cin >> x >> y >> l >> c;
adjList[x].push_back({y,l,c});
}
}
int main() {
vector<vector<Road>> adjList;
readNetwork(adjList);
cout << adjList.size();
return 0;
};
coutstatements to print out the values that you read from the cin and also before that to indicate that it's waiting for your input. As a side note, what does the variableTdo? And why do you have `` at the end of the input?