View Code of Problem 114

#include "stdio.h"
#include "string.h"

void main()
{	
	int i,j;
	int count=0;
	char s[100];
	//gets(s);
//	printf("%d",strlen(s));
	for(;gets(s)!=NULL;)
	{
		for(i=-1;s[i]!='\0';i++)
		{
			if(s[i+1]!=' '&&s[i+1]!='\0')
				count++;
			
			if(s[i+1]==' '||s[i+1]=='\0')
			{
				for(j=i;j>i-count;j--)
				{
					printf("%c",s[j]);
				}
				count=0;
				if(s[i+1]!='\0')
					printf(" ");
			}
			
		}
	}
}

Double click to view unformatted code.


Back to problem 114