View Code of Problem 3924

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main(void)
{
    string s = "";
    char c;
    while ((c = getchar()) != '\n')
    {
        if (s.length() == 0 || (s.length() != 0 && s[s.size() - 1] != c))
            s += c;
    }
    cout << s << endl;
}

Double click to view unformatted code.


Back to problem 3924