View Code of Problem 3924

#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	string s;
	string str;
	cin >> s;
	for(int i = 0; i < s.length()-1; i++)
		if(s[i] != s[i+1])
			str = str + s[i];
	if(s[s.length()-1] != s[s.length()-2])
		str = str + s[s.length()-1];
	cout << str << endl;
	return 0;
}

Double click to view unformatted code.


Back to problem 3924