Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <string.h>
- using namespace std;
- char s[256];
- void elim(int i, int k)
- {
- while (s[i] != '\0')
- {
- s[i - k] = s[i];
- i++;
- }
- s[i - k] = '\0';
- }
- int main()
- {
- cin >> s;
- int i = 0, k = 0;
- for (i = 0; i < strlen(s); i++)
- {
- if (tolower(s[i]) == tolower(s[i - 1]))
- k+=1;
- else
- {
- if (k != 0)
- {
- elim(i, k+1);
- i = 0;
- }
- k = 0;
- }
- if (s[i] == '\0')
- {
- s[i] = ' ';
- s[i + 1] = '\0';
- }
- }
- cout << s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement