View Code of Problem 105

#include<stdio.h>
#include<iostream>
#include<string.h>
int main()
{
	char str[2222],ss[2222];
	int a;
	while(scanf("%s",str))
	{
		if(strcmp(str,"END")==0)
		{
			break;
		}
		scanf("%d",&a);
		for(int i=1;i<=a;i++)	
		{
			scanf("%s",ss);
			if(strlen(str)==strlen(ss))
			{
				int j;
				for(j=0;j<strlen(str);j++)
				{
					if(ss[j]!=str[j])
					{
						cout<<i<<' '<<j+1<<" change "<<str[j]<<endl;
						break;
					}	
				}
				if(j==strlen(str))
				cout<<"OK!"<<endl;
			}
			else if(strlen(str)>strlen(ss))
			{
				for(int j=0;j<strlen(str);j++)
				{
					if(ss[j]!=str[j])
					{
						cout<<i<<' '<<j+1<<" insert"<<' '<<str[j]<<endl;
						break; 
					}
				}
			}
			else
			{
				for(int j=0;j<strlen(ss);j++)
				{
					if(ss[j]!=str[j]||j==strlen(ss)-1)
					{
						cout<<i<<' '<<j<<" delete"<<' '<<str[j-1]<<endl; 
						break;
					}
				}
			}
		}
	}
	return 0;

 } 
/*
Main.c:2:9: fatal error: iostream: No such file or directory
 #include<iostream>
         ^~~~~~~~~~
compilation terminated.
*/

Double click to view unformatted code.


Back to problem 105