http://acm.sgu.ru/problem.php?contest=0&problem=302
标签匹配的问题很多时候都用到栈。
#include <cstdio>
#include <cctype>
#include <stack>
using namespace std;
int main(void) {
    char s[1001];
    scanf ("%s", s);
    stack<bool> sta;
    char* t = s;
    while (*t) {
        if (*t == '<' && *(t+1) != '/') {
            if (*(t+1) == 'U') {
                sta.push(0);
                t += 4;
            } else {
                sta.push(1);
                t += 6;
            }
        } else if (*t == '<') {
            if (*(t+2) == 'U') {
                t += 5;
            } else {
                t += 7;
            }
            sta.pop();
        } else {
            if (sta.empty()) {
                putchar(*t++);
            } else if (sta.top()) {
                putchar(tolower(*t++));
            } else {
                putchar(toupper(*t++));
            }
        }
    }
    putchar('\n');
    return 0;
}