Home > Back-end >  Reverse string word (I love China into the I evol anihc) do?
Reverse string word (I love China into the I evol anihc) do?

Time:06-07

Strives for the big help, hope the way a little bit more simple

CodePudding user response:

2 d character array to store, the second dimension for loop reverse output directly

CodePudding user response:

With Spaces to as participle symbol, then reverse the output
 
#include
#include
#include
#include
using namespace std;

Int main () {
The string line;
Getline (cin, line);
int i=0;//start
For (int j=0; J & lt; The line length (); J++) {
If (j==line length () - 1 | | line [j]==' ') {
//segmentation and flip
Int k=(j==line length () - 1)? J: j - 1;
For (; K & gt;=I; K -) printf (" % c ", the line [k]);
(j==line length () - 1)? Printf (" \ n ") : printf (" ");
I=j + 1;//change the starting point of the
}
}
return 0;
}
/*
I love China
*/

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related