Advertisement
BRIGADA_9301

Untitled

Nov 21st, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <locale.h>
  3. #include <string.h>
  4. #include <Windows.h>
  5.  
  6. using namespace std;
  7.  
  8. const size_t NMAXCHAR = 451;
  9. const UCHAR NMAXWORDS = 50;
  10.  
  11. char is_it_polyndrome(char *str)
  12. {
  13. for (char i = 0; i < strlen(str) / 2; i++)
  14. {
  15. if (str[i] != str[strlen(str) - i - 1])
  16. return 0;
  17. }
  18. return 1;
  19. }
  20.  
  21. char is_it_equal(char *str, char *last_str)
  22. {
  23. if (strlen(str) == strlen(last_str))
  24. {
  25. for (char i = 0; i < strlen(str); i++)
  26. if (str[i] != last_str[i])
  27. return 0;
  28. }
  29. else
  30. return 0;
  31.  
  32. return 1;
  33. }
  34.  
  35. int main()
  36. {
  37. char word_sequence[NMAXWORDS][NMAXCHAR];
  38. char upd_word_sequence[NMAXWORDS][NMAXCHAR];
  39. char sz = -1;
  40. UCHAR upd_sz = 0;
  41.  
  42. do {
  43. sz++;
  44. scanf_s("%s", word_sequence[sz]);
  45. } while (word_sequence[sz][strlen(word_sequence[sz]) - 1] != '.');
  46.  
  47. for (UCHAR i = 0; i < sz; i++)
  48. {
  49. if (!is_it_equal(word_sequence[i], word_sequence[sz - 1]) || is_it_polyndrome(word_sequence[i]))
  50. {
  51. upd_word_sequence[upd_sz][0] = '\0';
  52. strcpy_s(upd_word_sequence[upd_sz], word_sequence[i]);
  53. upd_sz++;
  54. }
  55. }
  56.  
  57. for (UCHAR i = 0; i < upd_sz - 1; i++)
  58. {
  59. printf_s("%s ", upd_word_sequence[i]);
  60. }
  61. printf_s("%s.", upd_word_sequence[upd_sz - 1]);
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement