当前位置:网站首页>Clockwise rotation method of event arrangement -- PHP implementation
Clockwise rotation method of event arrangement -- PHP implementation
2022-07-04 12:05:00 【Take a glass of water from the sky】
// Clockwise rotation
public function clockwise()
{
$n = 7; // Number of teams , You can also directly pass in an array of team names , Index from 0 Start , example :[0=>' Yang Wei team ',1=>' Dawn team ',...]
if ($n % 2 == 0) {
$count = range(1, $n);
} else {
$count = range(1, $n + 1);
$count[$n] = 0;
}
$leftArr = array_slice($count, 0, count($count) / 2);
$rightArr = array_slice($count, count($count) / 2, count($count));
$tmp = [];
for ($i = 0; $i < count($count) / 2; $i++) {
$tmp[$i] = $rightArr[count($count) / 2 - $i - 1];
}
$rightArr = $tmp;
for ($i = 0; $i < count($count) - 1; $i++) {
echo ' The first ' . ($i + 1) . ' round </br>';
for ($j = 0; $j < count($leftArr); $j++) {
echo $leftArr[$j] . '---' . $rightArr[$j] . '</br>';
}
// Take the first element on the left
$x1 = $leftArr[0];
// Take the last element on the right
$x2 = $rightArr[count($rightArr) - 1];
for ($x = 0; $x < count($leftArr) - 1; $x++) {
$leftArr[$x] = $leftArr[$x + 1];
}
for ($x = 0; $x < count($rightArr) - 2; $x++) {
$rightArr[count($rightArr) - $x - 1] = $rightArr[count($rightArr) - $x - 2];
}
$leftArr[count($leftArr) -1] = $x2;
$rightArr[1] = $x1;
// $x1 = $leftArr[1];
// $x2 = $rightArr[count($rightArr) - 1];
// for ($x = 0; $x < count($leftArr) - 2; $x++) {
// $leftArr[$x + 1] = $leftArr[$x + 2];
// }
// for ($x = 0; $x < count($rightArr) - 1; $x++) {
// $rightArr[count($rightArr) - $x - 1] = $rightArr[count($rightArr) - $x - 2];
// }
// $leftArr[count($leftArr) -1] = $x2;
// $rightArr[0] = $x1;
}
}
边栏推荐
- In 2022, financial products are not guaranteed?
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17
- Common built-in modules
- Clion configuration of opencv
- 2021-08-09
- Function parameters (positional parameters, default value parameters, variable parameters, named keyword parameters, keyword parameters)
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 5
- QQ get group member operation time
- Awk getting started to proficient series - awk quick start
- Automatic translation between Chinese and English
猜你喜欢
QQ group administrators
Some summaries of the 21st postgraduate entrance examination 823 of network security major of Shanghai Jiaotong University and ideas on how to prepare for the 22nd postgraduate entrance examination pr
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 5
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
Detailed array expansion analysis --- take you step by step analysis
Attributes and methods in math library
Reptile learning 4 winter vacation series (3)
Day01 preliminary packet capture
Btrace tells you how to debug online without restarting the JVM
DVC use case (VI): Data Registry
随机推荐
Some summaries of the 21st postgraduate entrance examination 823 of network security major of Shanghai Jiaotong University and ideas on how to prepare for the 22nd postgraduate entrance examination pr
03_ Armv8 instruction set introduction load and store instructions
Experiment 7. IPv6
QQ group collection
2020 Summary - Magic year, magic me
Daemon xinted and logging syslogd
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
Four sorts: bubble, select, insert, count
VPS installation virtualmin panel
SSH principle and public key authentication
Data communication and network: ch13 Ethernet
The latest idea activation cracking tutorial, idea permanent activation code, the strongest in history
Exceptions and exception handling
QQ get group settings
Using terminal connection in different modes of virtual machine
No response after heartbeat startup
Day01 preliminary packet capture
thread
Postman advanced
(2021-08-20) web crawler learning 2