房间分配算法 [英] an algorithm for room allocation

查看:101
本文介绍了房间分配算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我需要一种算法来向人们分配房间.我需要重新整理房间列表以将房间分配给一个人,并且在将第四个人分配给房间后,它应该不在列表中(应该不可用).我还没有用PHP改组和排序功能的运气.
任何帮助(指针,引用等)将不胜感激.

Hi, I need help with an algorithm to allocate rooms to people. I need to shuffle through a list of rooms to assign a room to a person and after the fourth person is assigned to the room, it should be out of the list(should be unavailable). I have not had any luck with PHP shuffling and sorting functions yet.
Any help (pointers, references, etc.) will greatly be appreciated.

推荐答案

尝试简化您的过程.如果您有x个房间,则每当需要分配一个人时,只需对它们进行遍历.然后检查当前选定的房间.如果已满,请继续.
Try to simplify your process. If you have x number of rooms, simply iterate through them whenever a person needs to be allocated. Then check the currently selected room. If it is full, move on.


这篇关于房间分配算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆