#include <stdio.h> #include <string.h> void putUpper(char c) { if (c >= 'a') { //c is lowercase putchar(c - 32); } else { putchar(c); } } void putLower(char c) { if (c <= 'Z') { // c is Uppercase putchar(c + 32); } else { putchar(c); } } int main() { char s[1009]; char f[1009]; int k = 0; // f and k as stack, the last one is the nearest tag int i = 0; s[0] = '\0'; scanf("%s", s); while (s[i] != '\0') { if (s[i] == '<') { // si is a tag ++i; if (s[i] == '/'){ //si is the right tag, pop stack --k; } else { //si is the left tag, push stack ++k; f[k] = s[i]; } while (s[i] != '>') ++i; //i went to the end of tags } else { if (k == 0) { //si is not betwwen tag putchar(s[i]); } else if (f[k] == 'D') { //si si between DOWN tag putLower(s[i]); } else { //si is between UP tag putUpper(s[i]); } } ++i; } return 0; }
sgu 302
最新推荐文章于 2024-07-06 00:20:02 发布