当前位置:网站首页>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;
}
}
边栏推荐
- How to judge the advantages and disadvantages of low code products in the market?
- World document to picture
- QQ get group settings
- Clion configuration of opencv
- JD home programmers delete databases and run away. Talk about binlog, the killer of MySQL data backup
- 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
- What if the chat record is gone? How to restore wechat chat records on Apple Mobile
- How to deal with the relationship between colleagues
- re. Sub() usage
- Common tips
猜你喜欢
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13](/img/29/49da279efed22706545929157788f0.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9](/img/ed/0edff23fbd3880bc6c9dabd31755ac.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16](/img/c3/f3746b161012acc3751b2bd0b8f663.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20](/img/d5/4bce239b522696b5312b1346336b5f.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20

Replace() function
![[solve the error of this pointing in the applet] SetData of undefined](/img/19/c34008fbbe1175baac2ab69eb26e05.jpg)
[solve the error of this pointing in the applet] SetData of undefined

Analysis function in SQL
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12](/img/b1/926d9b3d7ce9c5104f3e81974eef07.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12

How to judge the advantages and disadvantages of low code products in the market?

Decrypt the advantages of low code and unlock efficient application development
随机推荐
Customized version of cacti host template
Supercomputing simulation research has determined a safe and effective carbon capture and storage route
Day01 preliminary packet capture
13、 C window form technology and basic controls (3)
Decrypt the advantages of low code and unlock efficient application development
Snowflake won the 2021 annual database
Iframe to only show a certain part of the page
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
8.8.1-PointersOnC-20220214
Sys module
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 14
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10
Configure SSH key to realize login free
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
Lecture 9
Function parameters (positional parameters, default value parameters, variable parameters, named keyword parameters, keyword parameters)
Recommend a cool geospatial data visualization tool with low code
Usage of with as
Map container