View Code of Problem 3924

#include <bits/stdc++.h>
using namespace std;
#define N 1000000

int main()
{
	string str;
	char s[N];
	while(getline(cin,str)) {
		int i,k=-1;
		s[++k] = str[0]; 
		for(i=1;i<str.length();i++) {
			if(str[i] != s[k]) {
				s[++k] = str[i];
			}
		}
		s[++k]='\0';
		cout<<s<<endl;
	}	
	return 0;
 } 

Double click to view unformatted code.


Back to problem 3924