当前位置:网站首页>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;
}
}
边栏推荐
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
- Some tips on learning database
- IO stream ----- open
- thread
- Xshell's ssh server rejected the password, failed to skip publickey authentication, and did not register with the server
- Practical dry goods: deploy mini version message queue based on redis6.0
- How to use the mongodb ID array to get multiple documents- How to get multiple document using array of MongoDb id?
- Workplace liquor bureau must pay attention to
- 'using an alias column in the where clause in PostgreSQL' - using an alias column in the where clause in PostgreSQL
- Day01 preliminary packet capture
猜你喜欢
How to create a new virtual machine
2021-08-09
Login operation (for user name and password)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 14
(August 9, 2021) example exercise of air quality index calculation (I)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
Function parameters (positional parameters, default value parameters, variable parameters, named keyword parameters, keyword parameters)
Entitas learning [3] multi context system
Properties and methods of OS Library
MySQL advanced review
随机推荐
thread
Application of slice
. Does net 4 have a built-in JSON serializer / deserializer- Does . NET 4 have a built-in JSON serializer/deserializer?
Games101 Lesson 8 shading 2 Notes
2021-08-09
Reptile learning 4 winter vacation series (3)
TCP fast retransmission sack mechanism
Local MySQL forget password modification method (Windows) [easy to understand]
Recommend a cool geospatial data visualization tool with low code
Global function Encyclopedia
VPS installation virtualmin panel
Function parameters (positional parameters, default value parameters, variable parameters, named keyword parameters, keyword parameters)
No response after heartbeat startup
QQ get group link, QR code
Data transmission in the network
Introduction of network security research direction of Shanghai Jiaotong University
Understanding of object
Ultimate bug finding method - two points
How to create a new virtual machine
QQ get group member operation time