CodePudding user response:
2 d character array to store, the second dimension for loop reverse output directlyCodePudding 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.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html