View Code of Problem 440

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

int main()
{
	int tab=0,blank=0,space=0,n,i;
	char str[100];
	scanf("%d",&n);
	getchar();
	while(n--)
	{
		while(gets(str))
		{
			space=0;
			if(strcmp(str,"##")!=0)
			{
				for(i=0;i<=strlen(str);i++)
				{
					if(str[i]=='\t')
					{
						tab++;
						space+=4;
					}
					else if(str[i]==' ')
					{
						space++;
					}
					else if(str[i]=='\0')
					{
						blank+=space;
						space=0;
					}
					else space=0;
				}
			}
			else
			{
				printf("%d tab(s) replaced\n%d trailing space(s) removed\n",tab,blank);
				tab=blank=space=0;
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 440