asked to store this string in reverse order and find the answer on the Internet, but there is a code that can not be understood. Is there any great god who can help me solve the problem?
I don"t know what str [len-i-1] means,
and what I do
asked to store this string in reverse order and find the answer on the Internet, but there is a code that can not be understood. Is there any great god who can help me solve the problem?
I don"t know what str [len-i-1] means,
and what I do
len is the total length of the str I subscript index
forehead floats by:
first, I is the index of the current object in the for loop, why does I < len/2 mean? this means that according to the length of the string, the number of loops is half the length, and then increments the loop until the end. Then, when looping, temp records the character currently looped out and swaps it with the index subscript character corresponding to it (previously misunderstood, meaning that if the character length is 100 and the current cycle to the subscript is 3, then its corresponding subscript is 96, and then swap the character of subscript 3 with the character of subscript 96). Finally puts (output? ) string
len is the total length, and len-1 is the subscript of the tail element.
so the way to realize this reverse order is to swap head to tail, head + I position and tail-I position, that is, str[ I] and strlen [len-1Mui].
I really don't understand. You can insert real numbers to enhance your understanding.
i = 0len-1-i =
i = 1len-1-i =
the reverse order is completed in turn.
Let me explain that
I
is the index (subscript) of the current element, and len-1-i
is the index (subscript) of the corresponding inverted element
//:
var str = 'abcd'
i 0 'a' len(4) -1 - i ()3 'd'
i 1 'b' len(4) -1 - i ()2 'c'
.....
Previous: Why the style of @ keyframes can't override the style of class
Next: React-router: NavLink's onlyActiveOnIndex= {true} cannot be used?
recently, we are going to do a leave function. Student A submitted an application for leave, which was then reviewed by teacher B, but later I found that I needed a reminder function on Wechat s message end. It seems that Wechat can only use template me...
1. Write the landing page with react, after calling the background data with axios, judge the route of the page to jump according to the return value, how to jump? 2.axios.get ( login login.action?username= +name+ &password= +pd, {) timeout: 1000...
The horizontal coordinates of echarts are not specifically marked, and the X coordinates do not have a grid to indicate. Here is a figure that specifies . js * * createChartSix() { this.$http .get(this.$api.dataChart) .then(rsp => { ...
sincerely ask for advice: < hr > I want to use node as the background to build a video streaming server. The front end is similar to Youku VOD. It can record the playback node function, and load the progress bar at any point (starting from the c...
I can succeed with this https: www.jianshu.com p 293., but it is a font-class reference and is displayed in monochrome. I d like a color one. dvahtmljs ...
various methods have been tried, including the simplest way to disable the thouchmove event directly. Has the Wechat browser under ios been unable to stop the rebound? ...
setting in state: this.state = {checkList: []}; checkList initializes it with an array of the same length as JsonPage: this.setState ({checkList:checkSaveCount}); checkSavaCount is the same length as the following JsonPage. the following creates...
in order to facilitate development, we plan to create a LNMP environment based on docker, which makes it much more convenient to change computers or unify the team s development environment. choreographed a docker-compose.yaml file with nginx, php-fp...
external network access domain name: https: api.baidu.com internal network domain name: http: local.baidu.com this domain name is inaccessible outside the network! It is 127.0.0.1 pointed to by a private network address. I use nginx reverse proxy ...
I need to implement in a chained promise function, any function error in the middle terminates the program, and can catch the error function, and then perform different operations according to different error functions. How can the following code be imp...
import React from react ; class PublicScreen extends React.Component { constructor(props) { super(props); this.getStyle = this.getStyle.bind(this); } getStyle() { const { width = 1920, height = 1080 } = this.pr...
I would like to ask what is wrong with this code. Thank you for your answers. ...
renderdphtmldvareturnapiBackend: apiBackend ...
is doing a question on Niuke.com. I encounter a problem: to achieve the function callIt, after the call meets the following conditions 1, the returned result is the result after calling fn 2, and the call parameter of fn is all the parameters after th...
https: blog.csdn.net baidu_3. I can configure domain according to his settings, but I want him to change it into a subdomain name such as xxx.ccc.com . How can I set it? do you want to transfer the domain name to the same IP? ServerName...
A timing examination system is triggered if the click event is triggered within 5 seconds, and if it is not triggered, the system marks the correct answer at the end of the countdown. How to implement ...
description: a regular match is given to the content of an input box, and the matching content is the product activation code. looks like this: "0C31-0B81-BB32-3094-0C31-0B81-BB32-3094 " Code: $( -sharplicenseCode ).keyup(function () { le...
1. The custom event triggers the click event of .cpcstartrefresh, but triggers 2 click events each time 2. The code is as follows: window.onmessage = function (e) { create an event object, var myEvent = document.createEvent( Event ); m...
I configured the MIME type of the file with the amr suffix in the apache configuration as application ms-download, Why it is a garbled page when opening a file in amr format using window.open in chrome, while a file in amr format can be successfully dow...
I got a set of data, which is to choose the type of question. How can I tell if I have chosen the right one answera: "Olympic Games " answerb: "Asian Games " answerc: "Paralympic Games " answerd: "University Games " id: "1772 " question: "f...