当前位置:网站首页>Anti clockwise rotation method of event arrangement -- PHP implementation
Anti clockwise rotation method of event arrangement -- PHP implementation
2022-07-04 12:05:00 【Take a glass of water from the sky】
// Counterclockwise rotation method
public function anticlockwise()
{
$n = 6;
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>';
}
$x1 = $leftArr[count($leftArr) - 1];
$x2 = $rightArr[0];
for ($x = 0; $x < count($leftArr) - 2; $x++) {
$leftArr[count($leftArr) - ($x + 1)] = $leftArr[count($leftArr) - ($x + 2)];
}
for ($x = 0; $x < count($rightArr) - 1; $x++) {
$rightArr[$x] = $rightArr[$x + 1];
}
$leftArr[1] = $x2;
$rightArr[count($rightArr) - 1] = $x1;
}
}
边栏推荐
- No response after heartbeat startup
- SSH principle and public key authentication
- Customized version of cacti host template
- Understanding of object
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
- 2021 annual summary - it seems that I have done everything except studying hard
- Global function Encyclopedia
- Configure SSH certificate login
- In 2022, financial products are not guaranteed?
- (2021-08-20) web crawler learning 2
猜你喜欢
Here, the DDS tutorial you want | first experience of fastdds - source code compilation & Installation & Testing
TCP fast retransmission sack mechanism
(August 9, 2021) example exercise of air quality index calculation (I)
Summary of Shanghai Jiaotong University postgraduate entrance examination module firewall technology
OSI model notes
Btrace tells you how to debug online without restarting the JVM
(2021-08-20) web crawler learning 2
Digital simulation beauty match preparation -matlab basic operation No. 6
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
nn. Exploration and experiment of batchnorm2d principle
随机推荐
Xshell's ssh server rejected the password, failed to skip publickey authentication, and did not register with the server
Lecture 9
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
Exceptions and exception handling
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11
C language memory layout
Postman advanced
Replace() function
Snowflake won the 2021 annual database
2021-11-02
nn. Exploration and experiment of batchnorm2d principle
Data transmission in the network
No response after heartbeat startup
DVC use case (VI): Data Registry
Shift EC20 mode and switch
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
The latest idea activation cracking tutorial, idea permanent activation code, the strongest in history
How to judge the advantages and disadvantages of low code products in the market?
Common tips
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19