void remove_roomint index 退房 if index = 0 && index roomssize roomseraseroomsbegin + index; 代码实现方式
:
1.定义一个函数remove_room,参数为int类型的index表示要退房的房间编号。
2.判断index是否在rooms的下标范围内。
3.如果是,则使用vector的erase函数删除指定下标的元素,即rooms.begin()+index。
4.如果不是,什么也不做。
完整代码如下:
原文地址: https://www.cveoy.top/t/topic/flxs 著作权归作者所有。请勿转载和采集!