Kodewick
开始学 →
入门←→0 / 60

班级合照

#047入门常用算法约 2 分钟

拍班级合照,大家从矮到高站一排。写 photo_line(heights):用 <algorithm> 里的 sort 把身高从小到大排好再返回。

示例
photo_line({150, 138, 145})→[138, 145, 150]
photo_line({})→[]
函数vector<int> photo_line(vector<int> heights)
main.cpp
#include <algorithm>
#include <vector>
using namespace std;

vector<int> photo_line(vector<int> heights) {
    // 在这里写:把 heights 排好
    return heights;
}
Ctrl + Enter 也能运行
结果

写好了先点「运行」试试示例,没问题再点「提交」。