Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- #include <string.h>
- #include <Windows.h>
- using namespace std;
- const size_t NMAXCHAR = 451;
- const UCHAR NMAXWORDS = 50;
- char is_it_polyndrome(char *str)
- {
- for (char i = 0; i < strlen(str) / 2; i++)
- {
- if (str[i] != str[strlen(str) - i - 1])
- return 0;
- }
- return 1;
- }
- char is_it_equal(char *str, char *last_str)
- {
- if (strlen(str) == strlen(last_str))
- {
- for (char i = 0; i < strlen(str); i++)
- if (str[i] != last_str[i])
- return 0;
- }
- else
- return 0;
- return 1;
- }
- int main()
- {
- char word_sequence[NMAXWORDS][NMAXCHAR];
- char upd_word_sequence[NMAXWORDS][NMAXCHAR];
- char sz = -1;
- UCHAR upd_sz = 0;
- do {
- sz++;
- scanf_s("%s", word_sequence[sz]);
- } while (word_sequence[sz][strlen(word_sequence[sz]) - 1] != '.');
- for (UCHAR i = 0; i < sz; i++)
- {
- if (!is_it_equal(word_sequence[i], word_sequence[sz - 1]) || is_it_polyndrome(word_sequence[i]))
- {
- upd_word_sequence[upd_sz][0] = '\0';
- strcpy_s(upd_word_sequence[upd_sz], word_sequence[i]);
- upd_sz++;
- }
- }
- for (UCHAR i = 0; i < upd_sz - 1; i++)
- {
- printf_s("%s ", upd_word_sequence[i]);
- }
- printf_s("%s.", upd_word_sequence[upd_sz - 1]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement