我做了這個腳本來分發一個星期工作的人,但沒有人可以在一天中工作一次以上,也必須每週工作6天,但仍然有些問題會導致一些問題人們只工作4天,一些工作更多。 問題:如何讓人們每週工作6天? ......我試圖做這樣說:Php腳本分發一個星期工作的人
<?php
$input = array("Mohamed ET Sidi", "Ahmed ET ibrahim", "senoud","Hamed Et abdou");
$rand_keys = array_rand($input, 4);
?>
<table border=1>
<tr>
<th> Samedi </th>
<th> Dimanche </th>
<th> Lundi </th>
<th> Mardi </th>
<th> Merecredi </th>
<th> Jeudi </th>
<th> Vendredi </th>
</tr>
<tr>
<?php
$counter_MS=0;
$counter_AI=0;
$counter_HA=0;
$last_shift = $input[2];
for($i=0;$i<7;$i++){
echo "<td>\n";
shuffle($input);
// controle no one Continu working
while ($input[0] == $last_shift) {
shuffle($input);
}
// no one work 7 days a week
while ($counter_MS == 6 && $input[0]="Mohamed ET Sidi" || $counter_MS == 6 && $input[1]="Mohamed ET Sidi" || $counter_MS == 6 && $input[2]="Mohamed ET Sidi") {
shuffle($input);
}
while ($counter_AI == 6 && $input[0]="Ahmed ET ibrahim" || $counter_MS == 6 && $input[1]="Ahmed ET ibrahim" || $counter_MS == 6 && $input[2]="Ahmed ET ibrahim") {
shuffle($input);
}
while ($counter_HA == 6 && $input[0]="Hamed Et abdou" || $counter_MS == 6 && $input[1]="Hamed Et abdou" || $counter_MS == 6 && $input[2]="Hamed Et abdou") {
shuffle($input);
}
if($input[0] =="Mohamed ET Sidi" || $input[1]=="Mohamed ET Sidi" || $input[2]=="Mohamed ET Sidi")
$counter_MS++;
if($input[0] =="Ahmed ET ibrahim" || $input[1]=="Ahmed ET ibrahim" || $input[2]=="Ahmed ET ibrahim")
$counter_AI++;
if($input[0] =="Hamed Et abdou" || $input[1]=="Hamed Et abdou" || $input[2]=="Hamed Et abdou")
$counter_HA++;
echo $input[0] ." 7H-15H\n" ;
echo $input[1] ." 15H-23H\n" ;
echo $input[2] ." 23H-7H\n" ;
$last_shift = $input[2];
echo "</td>\n";
}
echo "Mohamed Et Sidi Worked =".$counter_MS." days";
echo "Ahmed ET ibrahim =".$counter_AI." days";
echo "Hamed Et abdou =".$counter_HA." days";
?>
什麼是你的問題? – Blueblazer172
讓人每週工作6天 –
'這是一個聲明,而不是一個問題:P – Blueblazer172