Guest User

444

a guest
Dec 28th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. int main()
  7. {
  8. int k = 0, l, q, n = 0, i = 0, lengthtext = 0, lengthwords = 0;
  9. int count = 0;
  10. int flag = 0;
  11. char c;
  12. char her[2];
  13. char words[100];
  14. char text[2000] = { '0' };
  15. FILE* in;
  16. FILE* out;
  17. in = fopen("input.txt", "r");
  18. out = fopen("output.txt", "w");
  19. if (in == NULL)
  20. {
  21. printf("файл text.txt не открыт\n");
  22. }
  23. else
  24. {
  25. fscanf(in, "%s", words);
  26. //printf("%s\n", words);
  27. fgets(&text[i], 2000, in);
  28.  
  29. for (int k = 0; !feof(in); k++)
  30. {
  31. c = getc(in);
  32. text[k] = c;
  33. //printf("Element %c writed in %d\n", c, k);
  34. }
  35. lengthwords == strlen(words) - 1;
  36. lengthtext == strlen(text) - 1;
  37. while (k < lengthtext )
  38. {
  39.  
  40. for (int k = 0; k < lengthtext; k++)
  41. {
  42. if (words[i] == text[k] && text[k] != '\n' && text[k] != '\t' && text[k] != ' ')
  43. {
  44. for (int i = k; i <= lengthwords; l++)
  45. {
  46. if (words[i] == ' ' && (text[k] == '\n' || text[k] == ' ' || text[k] == '\t'))
  47. i++;
  48. if (words[i] == text[k])
  49. {
  50. k++;
  51. i++;
  52. }
  53. }
  54. }
  55. else
  56. k++;
  57. if (lengthwords == k)
  58. {
  59. lengthtext++;
  60. for (int i = lengthtext - 1; i >= n; i--)
  61. text[i + 1] = text[i];
  62. text[n] = '@';
  63. l++;
  64. }
  65. k = 0;
  66. l = 0;
  67. }
  68. }
  69. fprintf(out, "%s", text);
  70. fclose(in);
  71. fclose(out);
  72. }
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment