Silent1Snow

Untitled

Dec 19th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <iostream>
  4. #include <string.h>
  5.  
  6.  
  7. void in(char** &mass_f, char* &razd_f, int num_f, int* &kol_f);
  8.  
  9.  
  10. int main()
  11. {
  12. setlocale(LC_ALL, ".1251");
  13. char **txt = (char**)malloc(sizeof(char*) * 1);
  14. txt[0] = (char*)malloc(sizeof(char) * 1);
  15. char *razd = (char*)malloc(sizeof(char)*81);
  16. int num = 0;
  17. int *kol = (int*)malloc(sizeof(int)*1);
  18. in(txt, razd, num, kol);
  19. system("pause");
  20. return 0;
  21. }
  22.  
  23. void in(char** &mass_f, char* &razd_f, int num_f, int* &kol_f)
  24. {
  25. int sr_kol = 0;
  26. int p_kol = 0;
  27. int f_3 = 1;
  28. puts("Введите символы-разделители");
  29. scanf("%s", razd_f);
  30. do{
  31. char *str = (char*)malloc(sizeof(char) * 256);
  32. printf("Введите строку [%d]\n", (num_f + 1));
  33. scanf("%s", str);
  34. kol_f = (int*)realloc(kol_f, sizeof(int)*(num_f + 1));
  35. int len = strlen(str);
  36. int r_len = strlen(razd_f);
  37. mass_f = (char**)realloc(mass_f, sizeof(char*)*(num_f + 1));
  38. mass_f[num_f] = NULL;
  39. mass_f[num_f] = (char*)realloc(mass_f[num_f], sizeof(char)*(len + 1));
  40. strcpy(mass_f[num_f], str);
  41. int f = 1;
  42. int r_word = 0;
  43. int f_2 = 0;
  44. for (int i = 0; i < len; i++)
  45. {
  46. for (int j = 0; j < r_len; j++)
  47. {
  48. char a = str[i], b = razd_f[j];
  49. if (str[i] != razd_f[j] && f == 1)
  50. {
  51. f = 1;
  52. }
  53. else
  54. {
  55. f = 0;
  56. }
  57. }
  58. if (f == 1)
  59. {
  60. r_word++;
  61. }
  62. f = 1;
  63. }
  64. kol_f[num_f] = r_word;
  65. p_kol = p_kol + kol_f[num_f];
  66. if (num_f != 0)
  67. {
  68. sr_kol = (p_kol - kol_f[num_f]) / (num_f);
  69. }
  70. if (sr_kol == kol_f[num_f])
  71. {
  72. f_3 = 0;
  73. }
  74. num_f++;
  75. } while (f_3 == 1);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment