This article will arrange the words in the arrays to be arranged upside down, such as how old are you-> you are old how
Example program output results:
The first:
How old are you !? I do don't underStand
The Second:
undertond don'T't I?! You are old how
For example code
Public static void main (string [] args) {char [] chars = new string ("how old are you!? I do don'TERSTAND"). Tochararray (); Cure ; System.out.println (chars); reversewords (chars); // The main method system.out.println ("the sex:"); System.out.println (chars);} /*** will be in the group. Words are arranged, such as how old are you-> you are Old How * @param Chars */ Public Static Void Reverseword (Char [] chars) {REVERSECHARS (CHARS, CHARS.LENGTH -1); int b egin = -1 ; int end = 0; for (int i = 0; i <cHars.length; i ++) {char c = chars [i]; if ((c> = 'a' && c <= 'z') || > = 'A' && C <= 'Z') || C == '/' ') {// Simply judge whether it is a continuous word if (begin ==-1) {begin = i; end = I;} else {end = i; if (i == chars.length-) {reversechars (chars, begin, end);}} else {if (begin! =-1) {reviewchars (chars, begin, begin, end); Begin = -1; END = 0;}}} /*** The characters in the char in a certain range are arranged for example hello-> @param chars* @param Begin Start position* @param End Ending End Position*/ Public Static Void Reversechars (Char [] chars, int Begin, int End) {While (End> Begin) {char c = chars [begin]; begin [end]; chars [end] = c; begin ++; end-;}}The above is the use of Java to achieve the order of words. I hope it can be understood by everyone and help everyone