View Code of Problem 114

#include <stdio.h>
#include <string.h>

int main(void)
{
	char st[1001],st2[1001];
	int i,j,n,len,k=0,start=0;
	while (gets(st))
	{
		len = strlen(st);
		for (i=0; i<len; i++)
		{
			if ((st[i]==' ') || (i==len-1))
			{ 
				if (i==len-1)
				k = i;
				else
				k = i-1;
				for (j=k; j>=start; j--)
				printf("%c", st[j]);
				if (st[i]==' ')
				printf(" ");
				start = i+1;								
			}
		}
		printf("\n");
		start = 0; k = 0;
	}
}

Double click to view unformatted code.


Back to problem 114