Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- short isNotEqual(char tmpChar, char* usedChars) {
- for (int i = 0; i < strlen(usedChars); i++)
- if (usedChars[i] == tmpChar)
- return 0;
- return 1;
- }
- void findEqualElem(char* str) {
- char tmpChar;
- int counter = 0;
- char usedChars[50];
- for (int i = 0; i < strlen(str); i++) {
- tmpChar = str[i];
- for (int j = i + 1; j < strlen(str); j++)
- if (tmpChar == str[j] && (isNotEqual(tmpChar, usedChars) == 1))
- counter++;
- if (counter > 0)
- for (int j = 0; j <= counter; j++)
- printf("%c", tmpChar);
- counter = 0;
- usedChars[i] = tmpChar;
- }
- }
- int main() {
- printf("Enter the string: ");
- char str[80];
- gets(str);
- findEqualElem(str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement