Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string.h>
- void in(char** &mass_f, char* &razd_f, int num_f, int* &kol_f);
- int main()
- {
- setlocale(LC_ALL, ".1251");
- char **txt = (char**)malloc(sizeof(char*) * 1);
- txt[0] = (char*)malloc(sizeof(char) * 1);
- char *razd = (char*)malloc(sizeof(char)*81);
- int num = 0;
- int *kol = (int*)malloc(sizeof(int)*1);
- in(txt, razd, num, kol);
- system("pause");
- return 0;
- }
- void in(char** &mass_f, char* &razd_f, int num_f, int* &kol_f)
- {
- int sr_kol = 0;
- int p_kol = 0;
- int f_3 = 1;
- puts("Введите символы-разделители");
- scanf("%s", razd_f);
- do{
- char *str = (char*)malloc(sizeof(char) * 256);
- printf("Введите строку [%d]\n", (num_f + 1));
- scanf("%s", str);
- kol_f = (int*)realloc(kol_f, sizeof(int)*(num_f + 1));
- int len = strlen(str);
- int r_len = strlen(razd_f);
- mass_f = (char**)realloc(mass_f, sizeof(char*)*(num_f + 1));
- mass_f[num_f] = NULL;
- mass_f[num_f] = (char*)realloc(mass_f[num_f], sizeof(char)*(len + 1));
- strcpy(mass_f[num_f], str);
- int f = 1;
- int r_word = 0;
- int f_2 = 0;
- for (int i = 0; i < len; i++)
- {
- for (int j = 0; j < r_len; j++)
- {
- char a = str[i], b = razd_f[j];
- if (str[i] != razd_f[j] && f == 1)
- {
- f = 1;
- }
- else
- {
- f = 0;
- }
- }
- if (f == 1)
- {
- r_word++;
- }
- f = 1;
- }
- kol_f[num_f] = r_word;
- p_kol = p_kol + kol_f[num_f];
- if (num_f != 0)
- {
- sr_kol = (p_kol - kol_f[num_f]) / (num_f);
- }
- if (sr_kol == kol_f[num_f])
- {
- f_3 = 0;
- }
- num_f++;
- } while (f_3 == 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment