The code doesn't understand: I don't understand what the str [len-i-1] means and what I is used for.

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

.
C
Feb.28,2021

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'
                    ..... 
                    
                    
   

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3f509-2c48e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3f509-2c48e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?