第23836题 单选题
以下C++代码实现n位格雷码,横线处应填写的正确语句是?
#include <iostream>
#include <vector>
#include <string>
using namespace std;
// 生成 n 位的格雷码
vector<string> generate_graycode(int n) {
    vector<string> graycode_list;
    if (n <= 0) {
        return graycode_list;
    }

    // 初始1位格雷码
    graycode_list.push_back("0");
    graycode_list.push_back("1");

    // 迭代生成 n 位的格雷码
    for (int i = 2; i <= n; i++) {
        int current_size = graycode_list.size();

        for (int j = current_size - 1; j >= 0; j--) {
            graycode_list.push_back("1" + graycode_list[j]);
        }

        for (int j = 0; j < current_size; j++) {
            _________________________ // 在此处填入代码
        }
    }

    return graycode_list;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析