View Code of Problem 105

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

int  main()
{
	int i,j;
	int lena,lens;
	int n;
	char s[2223];
	char a[2223];
	for(;gets(s)!=NULL;)
	{
		int count=0;
		lens=strlen(s);
		if(strcmp(s,"END")==0)
			break;
		scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%s",a);
			lena=strlen(a);	
			if(lena==lens&&strcmp(s,a)==0)
				printf("%d OK!\n",i+1);
			else
			{
				for(j=0;a[j]!='\0'||s[j]!='\0';j++)							//以第一个不相同的为中心点
				{
					if(lena==lens)
					{
						if(a[j]!=s[j])
						{
							printf("%d %d change %c\n",i+1,j+1,s[j]);break;
						}
						
					}	
					if(lena<lens)
					{
						if(a[j]!=s[j])
						{
							printf("%d %d inesrt %c\n",i+1,j+1,s[j]);break;
						}
					}
					if(lena>lens)
					{
						if(a[j]==s[j-1]&&a[j]!=s[j])						
						{
							printf("%d %d delete %c\n",i+1,j,a[j-1]);break;
						}
					}
				}
			}
		}
	//	printf("*%d**",i);
		fflush(stdin);
	}
}

Double click to view unformatted code.


Back to problem 105