由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - reverse words, not the Microsoft one!!!
相关主题
这个程序怎么解决C++菜问: 怎么这样也可以?
A aimple C++ question没有经过构造函数???
为什么foo1可以而foo2不行?一个古怪的C程序运行错误。
菜鸟求教,一个c++的困惑请教这个程序里用到了什么constructor啊?有几个copy constructor?
问个缺少逗号的数组赋值问题[C++ boost::interprocess] 讨论贴
请教如何使用qsort() to sort string.c++ 得最基本问题
请问一个exception题目来,出个题
关于c++的constructor的面试题question about shift
相关话题的讨论汇总
话题: reverse话题: microsoft话题: words话题: char话题: str
进入Programming版参与讨论
1 (共1页)
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
4
上perl
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....
1 (共1页)
进入Programming版参与讨论
相关主题
question about shift问个缺少逗号的数组赋值问题
一个指向指针的指针的引用?请教如何使用qsort() to sort string.
问个char*的问题请问一个exception题目
这个地址咋回事?关于c++的constructor的面试题
这个程序怎么解决C++菜问: 怎么这样也可以?
A aimple C++ question没有经过构造函数???
为什么foo1可以而foo2不行?一个古怪的C程序运行错误。
菜鸟求教,一个c++的困惑请教这个程序里用到了什么constructor啊?有几个copy constructor?
相关话题的讨论汇总
话题: reverse话题: microsoft话题: words话题: char话题: str