View Code of Problem 3924

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    string a;
    char b[999];
    int k=0;
    cin>>a;
    for(int i=0;i<a.length()-1;i++){
        int j=i+1;
        if(a[i]!=a[j]){
            b[k++]=a[i];
            if(j==a.length()-1)
                b[k++]=a[j];
        }
        else if(a[i]==a[j]&&j==a.length()-1)
            b[k++]=a[j];
    }
        cout<<b<<endl;
}

Double click to view unformatted code.


Back to problem 3924