How to realize Java string reverse order and string flipping
This article mainly explains "Java string reverse order and string flipping how to achieve", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Java string reverse and string flipping how to achieve" it!
Given a string, reverse the string by word. For example, given "I LOVE YOU", the output is "YOU LOVE I". To simplify the problem, the string does not contain punctuation. There are two steps: 1 first get "I EVOL UOY" 2 in reverse order according to the words, and then get "YOU LOVE I" # include # include using namespace std;// in reverse order void ReverseWord (char*p, char* Q) {while (p < Q) {char temp = * p; * Q + = * Q; * Q-= temp. }} void ReverseTotal (char* src) {/ / these two pointers are used to determine the beginning and end boundary of a word char* pairsrcash / the first character of the word, char* qroomsrcapacter / point to a space or'\ 0' while (* Q! ='\ 0') {if (* qpendy1) {ReverseWord (p, qMus1); qroom+ / / point to the first character of the next word, pendq;} else {QQ words;}} ReverseWord (pdhoqko1); / / a pair of the last word in reverse order ReverseWord (src,q-1); / / a pair of whole sentences in reverse order} int main () {char src [] = {"I LOVE YOU"}; ReverseTotal (src); cout