阅读以下二叉树广度优先搜索的C++实现代码,补全while循环内的横线处代码:
#include <queue>
void bfs(TreeNode* root) {
if (root == NULL) return;
queue<TreeNode*> q;
q.push(root);
while (!q.empty()) {
// 在此处填入代码
cout << node->val << " ";
if (node->left) {
q.push(node->left);
}
if (node->right) {
q.push(node->right);
}
}
}