Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <locale.h>
- char tmp_sepr[81];
- char sepr[81];
- char line [81];
- char **x;
- char **y;
- int gq;
- ////////////////////////////////////////////////
- void enterSeperators()
- {
- int j=0, i;
- printf("Введите разделители: \n");
- printf("Vvedite razdeliteli: \n");
- gets(sepr);
- /*for(i=0; i<strlen(tmp_sepr); i++)
- {
- if(tmp_sepr[i] != ' ')
- {
- sepr[j] = tmp_sepr[i];
- j++;
- }
- }*/
- }
- ///////////////////////////////////////////////////
- void enterLines(int z)
- {
- int c=0;
- int i,k,l, j, n=0;
- l=0;
- char *r=(char*)malloc(strlen(sepr)*sizeof(char));
- //for(i=0; i<strlen(r); i++) r[i] = ' ';
- int f=0;
- x = (char**) malloc(sizeof(char**));
- //char r[3]={'2','2','2'};
- do
- {
- l=0;
- n=0;
- gets(line);
- x[c] = (char*) malloc(strlen(line)*sizeof(char));
- strcpy(x[c], line);
- printf("\nStroka: ");
- for(i=0;i<strlen(x[c]);i++)
- printf("%c",x[c][i]);
- printf("\n");
- for(i=0; i<strlen(line); i++)
- {
- for(j=0;j<strlen(r);j++)
- {
- if(x[c][i]==r[j]) {f=0; break;} else f=1;
- }
- for(j=0;j<strlen(sepr);j++)
- {
- if(x[c][i]==sepr[j] && f)
- {
- r[n]=sepr[j];
- l++;
- //printf("l=%i", l);
- n++;
- }
- }
- }
- c++;gq=c;
- printf(r);
- printf("\n%i\n", l);
- for(i=0; i<strlen(r); i++) r[i] = '0';
- }
- while(l<z);
- }
- /////////////////////////////////////////////////////
- void deleteWord(int z)
- {
- int c=1, n=0, i=0,j,fns,p;
- int flag,flag1,k,zap;
- int str=0,na4=0,q=0;
- y = (char**) malloc(sizeof(char**));
- y[c] = (char*) malloc(strlen(x[c])*sizeof(char));
- //////
- do
- {
- for(j=0;j<strlen(sepr);j++)
- {
- if(sepr[j]!=x[c][i])
- flag=1;
- else flag=0;
- }
- if(!flag)
- {
- for(p=i;p<z+i;p++)
- {
- for(j=0;j<strlen(sepr);j++)
- {
- if(sepr[j]!=x[c][p])
- flag1=1;
- else
- {
- flag1=0;
- zap=p;
- }
- }
- }
- }
- if(flag1)
- for (k=na4;k<i;k++)
- {
- y[c][q]=x[c][k];q++;
- }
- i=zap;na4=zap;
- }
- while(i<strlen(x[c]));
- /////
- /* do
- {
- for(j=0;j<strlen(sepr);j++)
- {
- if(x[c][i]==sepr[j])
- {
- fns=i;
- if((fns-str-1)<z)
- {
- str=i;break;
- }
- else
- {
- for(p=str;p<fns-1;p++)
- {
- y[c][p]=x[c][p];
- }
- str=fns;
- }
- }
- }
- i++;
- }
- while(i<strlen(x[c]));
- //for(i=0;i<strlen(y[c]);i++)
- //printf("%c ",y[c][i]);*/
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int z,c,i;
- enterSeperators();
- printf("Количество различных символов разделителей:\n");
- scanf("%d", &z);
- printf("\n");
- enterLines(z);
- printf ("Задайте длинну слова:\n");
- scanf("%d", &z);
- deleteWord(z);
- for (c=1;c<gq;c++)
- {
- for(i=0;i<strlen(y[c]);i++)
- printf("%c",y[c][i]);
- printf("%c\n");
- }
- return(0);
- }
- \
Add Comment
Please, Sign In to add comment