#include <stdio.h>
#include <string.h>
int fun1(char *str)
{
int i, len = strlen(str);
for(i = 0; i < len/2; i++)
{
char t = str[i];
str[i] = str[len - i -1];
str[len - i - 1] = t;
}
}
int fun2(char *str)
{
int k, i = 0, j = 0;
while(i < 16)
{
while(str[j +1] != ' '&&str[j + 1] != '\0')
{
j++;
}
for(k = 0; k < (j - i)/2 + 1; k++)
{
char t = str[i + k];
str[i + k] = str[j - k];
str[j - k] = t;
}
j += 2;
i = j;
}
}
int main(int argc, char **argv)
{
char str[] = "I love wuxiaoyan";//16
fun1(str);
fun2(str);
printf("I love wuxiaoyan\n");
printf("%s", str);
return 0;
}
#include <string.h>
int fun1(char *str)
{
int i, len = strlen(str);
for(i = 0; i < len/2; i++)
{
char t = str[i];
str[i] = str[len - i -1];
str[len - i - 1] = t;
}
}
int fun2(char *str)
{
int k, i = 0, j = 0;
while(i < 16)
{
while(str[j +1] != ' '&&str[j + 1] != '\0')
{
j++;
}
for(k = 0; k < (j - i)/2 + 1; k++)
{
char t = str[i + k];
str[i + k] = str[j - k];
str[j - k] = t;
}
j += 2;
i = j;
}
}
int main(int argc, char **argv)
{
char str[] = "I love wuxiaoyan";//16
fun1(str);
fun2(str);
printf("I love wuxiaoyan\n");
printf("%s", str);
return 0;
}