Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Java string reverse order and string flipping

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report