Advertisement
Guest User

Untitled

a guest
Jun 17th, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <windows.h>
  2. #include <locale.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <math.h>
  7.  
  8. int main()
  9. {
  10. system("chcp 1251 > nul");
  11. SetConsoleTitle("ОтветыМейлРу"); // Русские буквы
  12.  
  13. char delim[3] = ", ";
  14. char str[100];
  15. fgets(str, 100, stdin);
  16. fflush(stdin);
  17.  
  18. printf("%s\n", str);
  19.  
  20. char str2[100]=""; char str3[100];
  21. int lw, ls, chk, temp, i, j, lw2=0;
  22. strcpy(str3, str);
  23. printf("%s\n", str2);
  24. char *p = strtok(str, delim);
  25. do
  26. {
  27.  
  28. lw2 += strlen(p)+1;
  29. for(int i = 0; i < lw2; i++) str3[i] = '\0';
  30.  
  31. if(strstr(str3, p) == NULL)
  32. {
  33. strcat(str2, p);
  34. strcat(str2, " ");
  35. printf("%s\n", str2);
  36. }
  37. else
  38. {
  39. ls = strlen(str3);
  40. lw = strlen(p);
  41.  
  42. for(i = 0; i < ls; i++)
  43. {
  44. temp = i;
  45. for(j = 0; j < lw; j++)
  46. {
  47. if(str3[i] == p[j]) i++;
  48. }
  49. chk = i-temp;
  50. if(chk == lw)
  51. {
  52. i = temp;
  53. for(j = i; j < (ls - lw); j++) str3[j] = str3[j + lw];
  54. ls = ls - lw;
  55. str3[j] = '\0';
  56. }
  57. }
  58. }
  59. strcpy(str, str3);
  60. }while(p = strtok(NULL, delim));
  61.  
  62. printf("%s\n", str2);
  63.  
  64. printf("\n"); system("pause");
  65. return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement