主要:使用strtok函数(将字符串以空格分开)(若不了解strtok函数,我在其它文章已说明)
#include <stdio.h>
#include <string.h>
int main()
{
int i = 0;
int z = 0;
char* str[500001];当字符串全是以一个的字符,则有500001个
char arr[500001] = { '\0' }; 题目明确字符串<=500000
gets(arr);
str[z] = strtok(arr," ");
while( str[z] != NULL)
{
z++;
str[z] = strtok(NULL," ");
}
for( i = z - 1 ; i >= 0 ; i--)
{
if( i == z - 1)
{
printf("%s",str[i]);
}
else{
printf(" %s",str[i]);
}
}
return 0;
}