输入一行英文句子,以.为结尾,输出翻转后的单词,每个单词的位置不变,但内部字母翻转,如:you have an apple.输出为:uoy evah na elppa.
#include<stdio.h>
#include<string.h>
void reverse(char s[])
{
char temp;
int low,high,length,i=0;
length=strlen(s);
while(i<length - 1)
{
while(s[i]==' ' && i<length)
{
i++;
}
low=i;
while(s[i]!=' ' && i<length && s[i]!='.')
{
i++;
}
high=i-1;
while(low < high)
{
temp=s[low];
s[low]=s[high];
s[high]=temp;
low++;
high--;
}
}
}
void main()
{
char x[100];
gets(x);
reverse(x);
printf("%s\n",x);
}