View Code of Problem 114

//考察数组指针的运用
//考察while循环的判断
//二分法
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
int main()
{
	char str[100];
	while(gets(str)!=NULL)
	{
		int len=strlen(str);
		for(int i=0;i<len;i++)
		{
			if(isalpha(str[i]))//如果第一个是字母判断余下的是不是字母,截取该字符串并输出
			{
				int l=0;
				char b[100];
				while(isalpha(str[i]))
				{
					b[l++]=str[i++];
				}//现在该把b逆序输出了
				for(int j=l-1;j>=0;j--)
				{
					printf("%c",b[j]);
				}
				i--;
			}
			else
			{
				printf("%c",str[i]);
			}
			
		}
		printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 114