第37853题 单选题
小北的身高是 1.65 米。班上有 n 个小朋友,小北想和身高最接近自己的人交朋友。如果有多个小朋友 与小北的身高差相同,小北想和其中身高较矮的第一个小朋友做朋友。横线处应该填入的是( )。
int n, i;
float target, h, best_height, min_diff, diff;

cout << "请输入小朋友的人数: ";
cin >> n;
target = 1.65;
best_height = 0.0;
min_diff = 100.0;

for (i = 0; i < n; i++) {
    cout << "请输入第 " << (i + 1) << " 个小朋友的身高: ";
    cin >> h;

    if (h > target)
        diff = h - target;
    else
        diff = target - h;

    if (diff < min_diff) {
        min_diff = diff;
        best_height = h;
    } else if (diff == min_diff) {
        __________________
        __________________
    }
}

cout << "小北的朋友身高为:" << best_height;
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析