View Code of Problem 114

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int i,j;
	char a[10000];
	while(gets(a)!=NULL)
	{
		int r=0,k=0;
		char b[1000][100]={'\0'};
		for(i=strlen(a)-1;i>=0;i--)
		{
			if(a[i]!=' ')
			{
				b[r][k++]=a[i];
			}
			else
			{
				b[r][k]='\0';
				r++;
				k=0;
			}
		}	
		for(i=r;i>=0;i--)
		{
			printf("%s",b[i]);
			if(i>0) printf(" ");
		}
	}
	 return 0;
 } 

Double click to view unformatted code.


Back to problem 114