Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. short isNotEqual(char tmpChar, char* usedChars) {
  4. for (int i = 0; i < strlen(usedChars); i++)
  5. if (usedChars[i] == tmpChar)
  6. return 0;
  7. return 1;
  8. }
  9.  
  10. void findEqualElem(char* str) {
  11. char tmpChar;
  12. int counter = 0;
  13. char usedChars[50];
  14. for (int i = 0; i < strlen(str); i++) {
  15. tmpChar = str[i];
  16. for (int j = i + 1; j < strlen(str); j++)
  17. if (tmpChar == str[j] && (isNotEqual(tmpChar, usedChars) == 1))
  18. counter++;
  19. if (counter > 0)
  20. for (int j = 0; j <= counter; j++)
  21. printf("%c", tmpChar);
  22. counter = 0;
  23. usedChars[i] = tmpChar;
  24. }
  25. }
  26.  
  27. int main() {
  28. printf("Enter the string: ");
  29. char str[80];
  30. gets(str);
  31. findEqualElem(str);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement