题解 | #句子逆序#
句子逆序
http://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
C++递归
#include <iostream> using namespace std; void print(string s) { string s1,s2; int pos=s.find(' '); if(pos==string::npos) { cout<< s; return; } else { s2=s.substr(pos+1,s.size()-pos); s1=s.substr(0,pos); } print(s2); cout<<" "<<s1; } int main() { string s; getline(cin,s); print(s); }