Advertisement
Guest User

Untitled

a guest
Dec 25th, 2016
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. int checkWord(const char * w)
  2. {
  3. int cnt[256] = { 0 };
  4. while(*w) cnt[(unsigned char)(*w++)]++;
  5. for(int i = 0; i < 256; ++i)
  6. if (cnt[i] == 1) return 0;
  7. return 1;
  8. }
  9.  
  10. int main(int argc, const char * argv[])
  11. {
  12. char s[256];
  13. char * words[50];
  14. int idx = 0;
  15. puts("Введите последовательность символов");
  16. fgets( s, sizeof( s ) - 1, stdin ) )
  17. for(char * w = strtok(s," ."); w; w = strtok(NULL," ."))
  18. {
  19. if (checkWord(w)) words[idx++] = w;
  20. }
  21. —idx;
  22. for(int i = 0; i < idx-1; ++i)
  23. {
  24. if (strcmp(words[i],words[idx])) printf("%s\n",words[i]);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement