# ZeroJudge - f668: FJCU_109_Winter_Day1_Lab3 Adjacency Matrix 和 Adjacency List 練習 ### 題目連結:https://zerojudge.tw/ShowProblem?problemid=f668 ###### tags: `ZeroJudge` `模擬` ```cpp= #include <iostream> using namespace std; int main(){ cin.sync_with_stdio(false); cin.tie(nullptr); int vertices, edges, from, to; bool adjacency[11][11] = {}; cin >> vertices >> edges; while (edges--) { cin >> from >> to; adjacency[from][to] = adjacency[to][from] = true; } for (int i = 1; i <= vertices; ++i) { cout << i << ':'; for (int j = 1; j <= vertices; ++j) if (adjacency[i][j]) cout << ' ' << j; cout << '\n'; } } ```