Saturday, August 6, 2016

UVA 11988 - Broken Keyboard Solution

Unknown
#include<cstdio>
#include<cstring>
#include<list>
using namespace std;

int main()
{
    char s[100001];
    while (gets(s))
    {
        list <char> l;
        list <char> ::iterator it=l.begin();
        int len=strlen(s);
        for (int i=0;i<len;i++)
        {
            if (s[i]=='[') it =l.begin();
            else if (s[i]==']') it =l.end();
            else l.insert(it,s[i]);
        }
        for (it=l.begin();it!=l.end();it++)
            printf("%c",*it);
        printf("\n");
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,