Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <string>
- #include <cstddef>
- #include <iomanip>
- using namespace std;
- int main()
- {
- char src[256];
- int lengthOfWords = 0;
- char **words = NULL;
- gets(src);
- char *currWord = strtok(src, " ");
- while(currWord != NULL) {
- words = (char**) realloc(words, (lengthOfWords + 1) * sizeof(char*));
- int lengthOfCurrWord = strlen(currWord);
- words[lengthOfWords] = (char*)malloc(lengthOfCurrWord * sizeof(char));
- words[lengthOfWords] = currWord;
- lengthOfWords++;
- if (currWord != NULL) {
- currWord = strtok(NULL, " ");
- }
- }
- char result[256];
- for(int i = 0; i < lengthOfWords; i++) {
- int counterUniqueChars = 0;
- bool seen[26];
- for(int i = 0; i < 26; i++) seen[i] = false;
- int lengthOfCurrWord = strlen(words[i]);
- for(int j = 0; j < lengthOfCurrWord; j++) {
- const int symbol = (int) words[i][j];
- int indexOfChar = (symbol % 124) - 97;
- if(seen[indexOfChar] == false) {
- seen[indexOfChar] = true;
- counterUniqueChars++;
- }
- }
- if(counterUniqueChars > 2) {
- strcat(result, words[i]);
- strcat(result, " ");
- }
- }
- cout << "Result stinfg is: ";
- cout << result;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement