View Code of Problem 114

#include<stdio.h>
#include<string.h>
int main()
{
	char a[10000];
	while (gets(a))
	{
		int n ;
		int i;
		for (i = 0; a[i] != '\0'; i++)
		{
			n = 1;
			if ((a[i] >= 'a'&&a[i] <= 'z') || (a[i] >= 'A'&&a[i] <= 'Z'))
			{
				for (int j = i + 1; a[j] != '\0'; j++)
				{
					if ((a[j] >= 'a'&&a[j] <= 'z') || (a[j] >= 'A'&&a[j] <= 'Z'))
						n++;
					else
						break;
				}
				for (int k = i + n - 1; k >= i; k--)
				{
					printf("%c", a[k]);
				}
				i = i + n - 1;
			}
			else
			{
				printf("%c", a[i]);
			}	
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 114