View Code of Problem 114

#include<stdio.h>
#include<string.h>
void swag(char s[],int begin,int end)
{
	char temp;
	while(begin<end)
	{
		temp=s[begin];
		s[begin]=s[end];
		s[end]=temp;
		begin++;
		end--;
	}
}
int main()
{
	char s[100];
	while(gets(s))
	{
		int i,a,b,n;
		a=0,b=0;
		i=0;
		n=strlen(s);
		while(i<n)
		{
			while(s[i]==' '&&i<n)
				i++;
				a=i;
			while(s[i]!=' '&&i<n)
				i++;
				b=i-1;
			swag(s,a,b);
		}
		puts(s);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 114