900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 输入字符串“I am a student” 要求输出字符串“student a am I”

输入字符串“I am a student” 要求输出字符串“student a am I”

时间:2018-09-12 18:19:53

相关推荐

输入字符串“I am a student” 要求输出字符串“student a am I”

面试题目: 输入字符串“I am a student”,要求输出字符串“student a am I”

#include <stdio.h>

void main()

{

char src[] = "I am a stdutent";

char *temp_start = src;

char *temp_end = src;

while (*temp_end != '\0')

{

temp_end++;

}

temp_end--;

char temp;

while (temp_start < temp_end)

{

temp = *temp_start;

*temp_start = *temp_end;

*temp_end = temp;

temp_start++;

temp_end--;

}

//reverseal all

char *index = src;

printf("The src value is %s\n", src);

while (true)

{

temp_start = index;

while (*index != '\0' && *index != ' ')

{

++index;

}

temp_end = --index;

index++;

while (temp_start < temp_end)

{

temp = *temp_start;

*temp_start = *temp_end;

*temp_end = temp;

temp_start++;

temp_end--;

}

if (*index != '\0')

{

++index;

}

else

{

break;

}

}

printf("The src value is %s\n", src);

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。