View Code of Problem 105

#include <stdio.h>
#include <string.h>
int main(){
  char a[2223];
  int p,q;
  char b[2223];
  while (gets(a)!=NULL){
    if(strcmp(a,"END")==0)
      break;
    k=strlen(a);
    scanf("%d",&m);
    for(i=0;i<m;i++){
      num++;
      scanf("%s",b);
      k1=strlen(b);
      if(k1<k){
        for(p=0,q=0;q<k1;p++,q++){
          if(a[p]!=b[q]){
            printf("%d %d insert %c",num,p+1,a[p]);
            break;
          }
        }
        if(q==k1)
          printf("%d %d insert %c",num,p+1,a[p]);
        
        
          
         }
      else if(k1>k){
        for(p=0,q=0;p<k;p++,q++){
          if(a[p]!=b[q]){
            printf("%d %d delete %c",num,p+1,a[p]);
          break;
          }
        }
        if(p==k)
          printf("%d %d delete %c",num,p+1,a[p]");
         }
                 
                 else if(k1==k){
                   for(p=0,q=0;p<k,q<k1;p++,q++){
                     if(a[p]!=b[q]){
                       printf("%d %d change %c",num,p+1,a[p]);
                       break;
                     }
                   }
                   if(p==k)
                     printf("%d OK!",num);
                 }
                 
                 
                 
      }
    }
    
  
  
  
  
  
  
  return 0;
}
/*
Main.c: In function 'main':
Main.c:7:3: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
   while (gets(a)!=NULL){
   ^
Main.c:10:5: error: 'k' undeclared (first use in this function)
     k=strlen(a);
     ^
Main.c:10:5: note: each undeclared identifier is reported only once for each function it appears in
Main.c:11:17: error: 'm' undeclared (first use in this function)
     scanf("%d",&m);
                 ^
Main.c:12:9: error: 'i' undeclared (first use in this function)
     for(i=0;i<m;i++){
         ^
Main.c:13:7: error: 'num' undeclared (first use in this function)
       num++;
       ^
Main.c:15:7: error: 'k1' undeclared (first use in this function)
       k1=strlen(b);
       ^
Main.c:37:48: warning: missing terminating " character
           printf("%d %d delete %c",num,p+1,a[p]");
                                                ^
Main.c:37:11: error: missing terminating " character
           printf("%d %d delete %c",num,p+1,a[p]");
           ^
Main.c:38:10: error: expected ')' before '}' token
          }
          ^
Main.c:38:10: error: expected ';' before '}' token
Main.c:41:35: warning: left-hand operand of comma expression has no effect [-Wunused-value]
                    for(p=0,q=0;p<k,q<k1;p++,q++){
                                   ^
*/

Double click to view unformatted code.


Back to problem 105