Introduction
A beautiful programmer came to our team, I was secretly happy, haha, now is the opportunity. I'm thinking about how to start? Okay, let’s start with the QQ number. To find a goddess, you have to get a QQ number. Haha, I’m really a genius~~~
This is it
The idea is beautiful, but the reality is cruel. When looking for a goddess, you need a QQ number. , I didn’t expect that the goddess didn’t give it to me directly, but gave me a question (it was really a competition between programmers~~~). I was given all the questions. If I couldn’t do it, not only would I lose the opportunity to contact the goddess, Even the basic skill of making a living - programming ability has been questioned~~~The question is like this:
<code>给了一串数字(不是QQ号码),根据下面规则可以找出QQ号码:首先删除第一个数,紧接着将第二个数放到这串数字的末尾,再将第三个数删除,并将第四个数放到这串数字的末尾......如此循环,知道剩下最后一个数,将最后一个数也删除,按照刚才删除的顺序,把这些数字连在一起就是女神的QQ号码啦。</code>
That's it, the goddess gave a string of numbers 631758924, what you have to do now is to find from this number There are many ways to find out the QQ number of the goddess. For example, you can use 9 cards to write these 9 numbers respectively, and simulate the process of the question. You can calculate it, or you can use a pen to calculate it one by one~~~~
These methods are too low and do not show the ability of programmers. It would be cooler to write a program (actually, I am thinking that if I encounter a goddess asking such a question next time, the program will be very convenient, haha~ ~~)
Solution
The first method is to use mathematical methods and cycle the following operations according to the rules of the question: rounding => remainder => remainder * 10 + rounding. . . . . The objects of remainder rounding are all multiples of 10, depending on the number of digits. After each rounding, there is one digit, and the cycle continues until the number is equal to 0.
<code><?php $raw_num = 631758924; $num = 0; $devisor = 1; while($devisor < $raw_num) { $devisor *= 10; //获取最小的大于raw_num的10的倍数的整数 } while ($raw_num > 0) { $devisor /= 10; $next = floor($raw_num / $devisor); //获取下一个数字 $num = $num*10 + $next; //计算”半成品“QQ号码 $raw_num = $raw_num % $devisor; $last = floor($raw_num * 10 / $devisor); //移动数字,拼接最新的QQ号码 $pre = $raw_num % (ceil($devisor / 10)); $raw_num = $pre * 10 + $last; } echo "恭喜你啦,成功获取QQ号码:{$num}"; //恭喜你啦,成功获取QQ号码:615947283</code>
Use the FIFO of the queue to obtain the QQ number. According to the characteristics of the question, you can just use the queue to process it. The queue is simple, convenient, and easier to understand.
<code>#include<stdio.h> struct queue { int *data; int head; int tail; }; int main() { int num, i; printf("请输出要破译的QQ号码长度:"); scanf("%d", &num); struct queue q; q.data = (int *)malloc(sizeof(int)*(num*2-1)); //总共需要的数组长度为num*2-1 q.head = 0; q.tail = 0; for(i=1;i</stdio.h></code>
Say something
The idea for this article comes from "Aha!" In Chapter 2, Section 1 [Decrypting QQ Numbers - Queue] in "Algorithm", the only illustration is also taken from this book.
WeChat ID: love_skills
The harder you work, the luckier you will be! The luckier you are, the harder you work!
Being a CEO is not a dream
Winning Bai Fumei is not a dream
Disi counterattack is not a dream
It’s now! ! Come on
The above is an introduction to asking for a QQ number from a goddess, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
