洗ったお皿が水切りかごに重なっています。上から 1 枚ずつ取って食器棚に重ねます。move_one(from, to) を書きましょう。from の最後のお皿を取って to の最後に置きます。from が空なら何もしません。どちらも参照なので、両方が変わります。
stacked({"blue", "white", "red"}, 2)→['red', 'white']stacked({"blue"}, 3)→['blue']vector<string> stacked(vector<string> rack, int n)#include <string>
#include <vector>
using namespace std;
void move_one(vector<string> &from, vector<string> &to) {
// ここにコードを書く:from の最後のお皿を to に移す
}
vector<string> stacked(vector<string> rack, int n) {
vector<string> cupboard;
for (int i = 0; i < n; i++) {
move_one(rack, cupboard);
}
return cupboard;
}
実行すると例で試せます。よさそうなら提出しましょう。