Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- #include <string.h>
- #include <ctype.h>
- #include <stdlib.h>
- #define SPR (" ,.") /* разделители */
- #define HEX_SYMBOLS ("0123456789abcdef") /* Цифры 16-ой с/c */
- #define TEXT_LEN (2048) /* Максимальная длина текста */
- int main()
- {
- setlocale(LC_ALL, "Russian");
- /* Ввод текста */
- char text[TEXT_LEN + 1]; /* Массив, хранящий символы */
- printf("Введите строку: ");
- gets(text);
- char* str = strtok(text, SPR); /* получить первую лексему */
- while (str != NULL)
- {
- int isHexLex = 1; /* лексема состоит из цифр 16 с/c */
- /* проверяем все элементы лексемы */
- for (int i = 0; i < strlen(str); ++i)
- {
- /* если проверяемый символ не является цифрой 16 c/c */
- if (!strchr(HEX_SYMBOLS, tolower(str[i])))
- {
- isHexLex = 0; /* лексема не состоит из цифр 16 с/c */
- break;
- }
- }
- /* если лексема состоит из цифр 16 c/c */
- if (isHexLex)
- {
- printf("%s\n", str); /* вывести его */
- }
- str = strtok(NULL, SPR); /* получить следующую лексему */
- }
- //system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement