sabertooth09

string 2/

Nov 6th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.26 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     char a[1000],b[100],c[100];
  7.     int i,j,k=1,l,m;
  8.     gets(a);
  9.     //a='\0';
  10.     char *pa=a,*temp,*z;
  11.     gets(b);
  12.     gets(c);
  13.     int lb=strlen(b),la=strlen(a),lc=strlen(c);
  14.     char *pb=b, *pc=c;
  15.     for(i=0;i<la;i++){
  16.         k=1;
  17.         if((*pa)==(*pb)){
  18.  
  19.             for(j=0;j<lb;j++){
  20.                 if((*pa)!=(*pb)){
  21.                     k=0;
  22.                     pa-=j;
  23.                     pb-=j;
  24.                     break;
  25.                 }
  26.                 else{
  27.                     pa++;
  28.                     pb++;
  29.                 }
  30.             }
  31.             if(k && (lb>lc)){
  32.                 pa-=lb;
  33.                 pb-=lb;
  34.                 for(l=0;l<lc;l++){
  35.                     (*pa)=(*pc);
  36.                     pa++;
  37.                     pc++;
  38.                 }
  39.  
  40.                 if(lb>lc){
  41.                     pc-=lc;
  42.                     int t=0;
  43.                     temp=pa+(lb-lc);
  44.                     while((*pa)!='\0'){
  45.                         (*pa)=(*temp);
  46.                         temp++;
  47.                         pa++;
  48.                         t++;
  49.                     }
  50.                     temp=0;
  51.                     pa-=t;
  52.                 }
  53.                 /*else if(lb<lc){
  54.                     temp=la+(lc-lb);
  55.                     while(x!=i+)
  56.                 }*/
  57.             }
  58.             else if(k && (lc>lb)){
  59.                 z=pa;
  60.                 pa+=(la-(i+j));
  61.                 temp=pa+(lc-lb);
  62.                 m=0;
  63.                 while((z)!=(pa)){
  64.                     (*temp)=(*pa);
  65.                     temp--;
  66.                     pa--;
  67.  
  68.                 }
  69.                 pa-=lb;
  70.                 pb-=lb;
  71.                 for(l=0;l<lc;l++){
  72.                     (*pa)=(*pc);
  73.                     pa++;
  74.                     pc++;
  75.                     //m++;
  76.                 }
  77.                 //pa+=lc;
  78.  
  79.             }
  80.             else if(k){
  81.                 pa-=lb;
  82.                 pb-=lb;
  83.                 for(l=0;l<lc;l++){
  84.                     (*pa)=(*pc);
  85.                     pa++;
  86.                     pc++;
  87.                 }
  88.                 pc-=lc;
  89.             }
  90.  
  91.         }
  92.         else{
  93.             pa++;
  94.         }
  95.     }
  96.     puts(a);
  97.  
  98. }
Add Comment
Please, Sign In to add comment