View Code of Problem 114

#include<stdio.h>
#include<string.h>
//断字符ch是否为英文字母,若为英文字母,返回非0(小写2,大写为1)
//若不是字母,返回0。
#include<ctype.h>
int main(){
	int i,j,n,m,len;
	char s[100],t;
	while(gets(s))
	{
		len=strlen(s);
		i=0;
		n=0;
		while(s[i]!='\0')
		{
			while( !isalpha(s[i]))
				i++;
			   n=i;
			while(isalpha(s[i]))
			     i++;
			   m=i-1;				
			for(j=n;j<=(m+n)/2;j++)
			{
			    t=s[j];s[j]=s[n+m-j];s[n+m-j]=t;  //换;
			}
		}
		puts(s);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 114