s**p 发帖数: 3 | 1 Just find this interview question, which is different from the classic
problem of reversing words in a sentence and seems much more difficult.
Any thoughts on it? |
j*******a 发帖数: 101 | 2 i wrote one. it works well.
#include
using namespace std;
char* reverse_word (char* str);
int main(int argc, char** argv){
char str[] = "this is very beautiful ";
cout <<"["<
cout << "["<< reverse_word(str)<<"]"<
char str2[] = "jokeslala rejected some 100k offers ";
cout <<"["<
cout << "["<< reverse_word(str2)<<"]"<
system("pause");
return 0;
}
char* reverse_word (char* str){
if (str =
【在 s**p 的大作中提到】 : Just find this interview question, which is different from the classic : problem of reversing words in a sentence and seems much more difficult. : Any thoughts on it?
|
s**p 发帖数: 3 | 3 Nice work. Well done.
Thanks.
【在 j*******a 的大作中提到】 : i wrote one. it works well. : #include : using namespace std; : char* reverse_word (char* str); : int main(int argc, char** argv){ : char str[] = "this is very beautiful "; : cout <<"["<: cout << "["<< reverse_word(str)<<"]"<: char str2[] = "jokeslala rejected some 100k offers "; : cout <<"["<
|
t****t 发帖数: 6806 | |
w*******u 发帖数: 131 | 5 then you should try python:
because this is the solution in python:
''.join(reversed(re.split(r'(\s+)', str1)))
almost the same as your ideal case.... |