当前位置:网站首页>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;
}
}
边栏推荐
- Leetcode: 408 sliding window median
- CSDN documentation specification
- Review of week 278 of leetcode II
- Local MySQL forgot the password modification method (Windows)
- Dos and path
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11
- Getting started with window functions
- template<typename MAP, typename LIST, typename First, typename ... Keytypes > recursive call with indefinite parameters - beauty of Pan China
- 03_ Armv8 instruction set introduction load and store instructions
- Object. Assign () & JS (= >) arrow function & foreach () function
猜你喜欢
JD home programmers delete databases and run away. Talk about binlog, the killer of MySQL data backup
Practical dry goods: deploy mini version message queue based on redis6.0
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 5
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
Summary of Shanghai Jiaotong University postgraduate entrance examination module firewall technology
(August 10, 2021) web crawler learning - Chinese University ranking directed crawler
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
OSI seven layer model & unit
os. Path built-in module
随机推荐
03_ Armv8 instruction set introduction load and store instructions
Local MySQL forget password modification method (Windows) [easy to understand]
Data communication and network: ch13 Ethernet
Reptile learning 3 (winter vacation learning)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10
Data transmission in the network
Postman advanced
If function in SQL
re. Sub() usage
Getting started with window functions
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
Customized version of cacti host template
Summary of Shanghai Jiaotong University postgraduate entrance examination module -- cryptography
2021-11-02
queue
. Does net 4 have a built-in JSON serializer / deserializer- Does . NET 4 have a built-in JSON serializer/deserializer?
SAP ui5 date type sap ui. model. type. Analysis of the display format of date
Xshell's ssh server rejected the password, failed to skip publickey authentication, and did not register with the server
SQL greatest() function instance detailed example
Btrace tells you how to debug online without restarting the JVM