33,027
社区成员




#include <iostream.h>
#include <string.h>
char *reverse(char * src)
{
char *start = src;
char *result = new char[strlen(src)+1];//
memset(result,0,sizeof(result));//
char *end = start+strlen(src)-1;//
while(*end != *start )//
{
if(*end == ' ')//
{
strcat(result,end+1);//
strcat(result," ");//
*end = 0;//
end --;//
}
else
{
end --;//
}
}
strcat(result,end);//
return result;
}
void main()
{
char a[] = "who are you :)";
char * p = reverse(a);
cout<<"The result is: "<<p<<endl;
}