当前位置:网站首页>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;
}
}
边栏推荐
- Workplace liquor bureau must pay attention to
- . Does net 4 have a built-in JSON serializer / deserializer- Does . NET 4 have a built-in JSON serializer/deserializer?
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
- QQ one click cookie acquisition
- Summary of collection: (to be updated)
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
- OSI seven layer model & unit
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
- QQ get group information
猜你喜欢

Serialization oriented - pickle library, JSON Library

MySQL advanced review

The latest idea activation cracking tutorial, idea permanent activation code, the strongest in history

Notes on writing test points in mind mapping

Login operation (for user name and password)

Simple understanding of seesion, cookies, tokens
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24](/img/2e/b1f348ee6abaef24b439944acf36d8.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24

OSI model notes

CSDN documentation specification
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13](/img/29/49da279efed22706545929157788f0.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
随机推荐
LxC shared directory permission configuration
Xshell's ssh server rejected the password, failed to skip publickey authentication, and did not register with the server
[solve the error of this pointing in the applet] SetData of undefined
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
Some tips on learning database
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17
SAP ui5 date type sap ui. model. type. Analysis of the display format of date
If function in SQL
Detailed array expansion analysis --- take you step by step analysis
Climb Phoenix Mountain on December 19, 2021
Experiment 7. IPv6
Lvs+kept realizes four layers of load and high availability
Btrace tells you how to debug online without restarting the JVM
2021-10-20
(August 10, 2021) web crawler learning - Chinese University ranking directed crawler
nn. Exploration and experiment of batchnorm2d principle
Practical dry goods: deploy mini version message queue based on redis6.0
Heartbeat error attempted replay attack
How do std:: function and function pointer assign values to each other
Understanding of object