Also in the task you need to put a space between the same characters, but it was possible to implement it.
Already 2 weeks I am trying to decide, about 10 hours spent during this time, but everything does not succeed. I decided to ask on the forums, and here came here.
Answer 1, Authority 100%
Somehow so
std :: string st = "abbcccabbccc";
std :: unique_copy (st.begin (), st.end (), std :: ostreambuf_terator & lt; char & gt; (std :: cout));
STD :: COUT & LT; & LT; '\ n';
Answer 2
ABYX working option. I can offer my own, it may be more understandable for you. If something is incomprehensible, ask questions 🙂
# include & lt; iostream & gt;
Using Namespace STD;
INT MAIN () {
STRING S, RESULT; // S - Initial Row, Result - Finite
char prev; // Last non-repeating symbol we met
CIN & GT; & GT; s;
Prev = S [0];
result + = s [0];
For (int i = 1; i & lt; s.size (); i ++) {
if (s [i]! = prev) {
prev = s [i];
result + = s [i];
}
}
COUT & LT; & LT; result;
Return 0;
}
Answer 3
In the end, I decided 🙂
#include & lt; iostream & gt;
Using Namespace STD;
INT MAIN ()
{
int n, m;
String ST, STD;
CIN & GT; & GT; ST;
For (n = 0; N & LT; st.Size (); n ++) {
IF (ST [N] == ST [N + 1]) {
ST.ERASE (N, 1);
}
}
STD = ST;
For (n = 0; N & LT; st.Size (); n ++) {
For (m = n + 1; m & lt; std.size () + 1; m ++) {
IF (ST [N] == STD [M]) {
STD.ERASE (M, 1);
}
}
}
COUT & LT; & LT; STD;
}
Answer 4
The function using iterators removes repeating characters from a string at the input and returns the result
string deleteduplicates (String Str) {
For (String :: ITERATOR IT1 = STR.BEGIN (); it1! = str.end (); ++ IT1) {
For (String :: Iterator It2 = it1 + 1; it2! = str.end ();) {
if (* IT1 == * IT2) {
STR.ERASE (IT2);
}
ELSE {
++ IT2;
}
}
}
Return str;
}
Answer 5
Removes from the line a repeating symbol I think to understand
for (int i = 0; i & lt; k.size ();) {
if (used [k [i]])
a.ERASE (I, I + 1);
ELSE.
{
Used [k [i]] = 1;
++ I;
}