当前位置:网站首页>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;
}
}
边栏推荐
- Object. Assign () & JS (= >) arrow function & foreach () function
- Foreach (system.out:: println) usage
- Install freeradius3 in the latest version of openwrt
- Using terminal connection in different modes of virtual machine
- Reptile learning 4 winter vacation series (3)
- Configure SSH certificate login
- Leetcode: 408 sliding window median
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
- Application of slice
- Take advantage of the world's sleeping gap to improve and surpass yourself -- get up early
猜你喜欢

Practical dry goods: deploy mini version message queue based on redis6.0

2018 meisai modeling summary +latex standard meisai template sharing

13、 C window form technology and basic controls (3)
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13](/img/29/49da279efed22706545929157788f0.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13

Introduction of network security research direction of Shanghai Jiaotong University

Replace() function

TCP slicing and PSH understanding

Here, the DDS tutorial you want | first experience of fastdds - source code compilation & Installation & Testing

Method of setting default items in C # ComboBox control code

QQ group administrators
随机推荐
Here, the DDS tutorial you want | first experience of fastdds - source code compilation & Installation & Testing
2021-10-20
Properties and methods of OS Library
No response after heartbeat startup
SSH principle and public key authentication
Analysis function in SQL
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
Summary of Shanghai Jiaotong University postgraduate entrance examination module -- cryptography
DDS-YYDS
re. Sub() usage
Customized version of cacti host template
Iptables cause heartbeat brain fissure
In 2022, financial products are not guaranteed?
QQ get group information
Postman advanced
2021-11-02
Automatic translation between Chinese and English
How to create a new virtual machine
Video analysis
Clion configuration of opencv