Guest User

Untitled

a guest
May 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <locale.h>
  5. char tmp_sepr[81];
  6. char sepr[81];
  7. char line [81];
  8. char **x;
  9. char **y;
  10. int gq;
  11.  
  12. ////////////////////////////////////////////////
  13. void enterSeperators()
  14. {
  15.     int j=0, i;
  16.     printf("Введите разделители: \n");
  17.     printf("Vvedite razdeliteli: \n");
  18.     gets(sepr);
  19.     /*for(i=0; i<strlen(tmp_sepr); i++)
  20.     {
  21.         if(tmp_sepr[i] != ' ')
  22.         {
  23.             sepr[j] = tmp_sepr[i];
  24.             j++;
  25.         }
  26.     }*/
  27. }
  28.  
  29. ///////////////////////////////////////////////////
  30.  
  31. void enterLines(int z)
  32. {
  33.     int c=0;
  34.     int i,k,l, j, n=0;
  35.     l=0;
  36.     char *r=(char*)malloc(strlen(sepr)*sizeof(char));
  37.     //for(i=0; i<strlen(r); i++) r[i] = ' ';
  38.     int f=0;
  39.     x = (char**) malloc(sizeof(char**));
  40.     //char r[3]={'2','2','2'};
  41.     do
  42.     {
  43.         l=0;
  44.         n=0;
  45.         gets(line);
  46.         x[c] = (char*) malloc(strlen(line)*sizeof(char));
  47.         strcpy(x[c], line);
  48.         printf("\nStroka: ");
  49.         for(i=0;i<strlen(x[c]);i++)
  50.             printf("%c",x[c][i]);
  51.             printf("\n");
  52.  
  53.         for(i=0; i<strlen(line); i++)
  54.         {
  55.             for(j=0;j<strlen(r);j++)
  56.             {
  57.                 if(x[c][i]==r[j]) {f=0; break;} else f=1;
  58.  
  59.             }
  60.  
  61.             for(j=0;j<strlen(sepr);j++)
  62.             {
  63.                 if(x[c][i]==sepr[j] && f)
  64.                 {
  65.                     r[n]=sepr[j];
  66.                     l++;
  67.                     //printf("l=%i", l);
  68.                     n++;
  69.  
  70.                 }
  71.             }
  72.  
  73.         }
  74.  
  75.         c++;gq=c;
  76.         printf(r);
  77.         printf("\n%i\n", l);
  78.        for(i=0; i<strlen(r); i++) r[i] = '0';
  79.     }
  80.     while(l<z);
  81. }
  82.  
  83. /////////////////////////////////////////////////////
  84.  
  85. void deleteWord(int z)
  86. {
  87.     int c=1, n=0, i=0,j,fns,p;
  88.     int flag,flag1,k,zap;
  89.     int str=0,na4=0,q=0;
  90.     y = (char**) malloc(sizeof(char**));
  91.     y[c] = (char*) malloc(strlen(x[c])*sizeof(char));
  92.    //////
  93.    do
  94.    {
  95.        for(j=0;j<strlen(sepr);j++)
  96.        {
  97.            if(sepr[j]!=x[c][i])
  98.            flag=1;
  99.            else flag=0;
  100.  
  101.        }
  102.        if(!flag)
  103.        {
  104.        for(p=i;p<z+i;p++)
  105.        {
  106.            for(j=0;j<strlen(sepr);j++)
  107.            {
  108.                 if(sepr[j]!=x[c][p])
  109.                 flag1=1;
  110.                 else
  111.                 {
  112.                     flag1=0;
  113.                     zap=p;
  114.                 }
  115.            }
  116.        }
  117.        }
  118.        if(flag1)
  119.        for (k=na4;k<i;k++)
  120.        {
  121.            y[c][q]=x[c][k];q++;
  122.        }
  123.     i=zap;na4=zap;
  124.    }
  125.    while(i<strlen(x[c]));
  126.    /////
  127.  
  128.   /*  do
  129.     {
  130.         for(j=0;j<strlen(sepr);j++)
  131.         {
  132.             if(x[c][i]==sepr[j])
  133.             {
  134.                 fns=i;
  135.                 if((fns-str-1)<z)
  136.                 {
  137.                     str=i;break;
  138.                 }
  139.  
  140.                 else
  141.                 {
  142.                     for(p=str;p<fns-1;p++)
  143.                     {
  144.                         y[c][p]=x[c][p];
  145.                     }
  146.                     str=fns;
  147.                 }
  148.  
  149.  
  150.             }
  151.         }
  152.         i++;
  153.     }
  154.     while(i<strlen(x[c]));
  155.  
  156. //for(i=0;i<strlen(y[c]);i++)
  157.  
  158. //printf("%c ",y[c][i]);*/
  159. }
  160.  
  161. int main()
  162. {
  163.     setlocale(LC_ALL, "Russian");
  164.     int z,c,i;
  165.     enterSeperators();
  166.     printf("Количество различных символов разделителей:\n");
  167.     scanf("%d", &z);
  168.     printf("\n");
  169.     enterLines(z);
  170.     printf ("Задайте длинну слова:\n");
  171.     scanf("%d", &z);
  172.     deleteWord(z);
  173.     for (c=1;c<gq;c++)
  174.     {
  175.  
  176.         for(i=0;i<strlen(y[c]);i++)
  177.             printf("%c",y[c][i]);
  178.  
  179.         printf("%c\n");
  180.     }
  181.     return(0);
  182. }
  183.  
  184. \
Add Comment
Please, Sign In to add comment