模拟。其实这题就是题目比较长而已。。。读完题目就差不多了。tag直接读就可以了,题目说了不用修改。然后整个题目就是让求text部分,严格按空格分开。注意每行前面空格个数。

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define REP(i, n) for(int i=0; i<n; i++)
#define FF(i, a, b) for(int i=a; i<b; i++)
#define FD(i, a, b) for(int i=a; i>=b; i--)
#define CLR(a, b) memset(a, b, sizeof(a))
#define PB push_back
#define LL long long
using namespace std; const int N = 1000;
char ch[N], c;
vector<string> ans;
char stop[10] = "</html>"; int main()
{
//freopen("input.txt", "r", stdin);
int t, cas = 1;
scanf("%d", &t);
while(t --)
{
int cnt = 0;
ans.clear();
c = getchar();
while(true)
{
while(c == ' ' || c == '\n' || c == '\t') c = getchar();
if(c == '<')
{
ch[cnt ++] = '<';
while(c != '>')
{
c = getchar();
ch[cnt ++] = c;
}
ch[cnt] = '\0';
ans.push_back(ch);
cnt = 0;
if(!strcmp(ch, stop))
{
break;
}
c = getchar();
}
else
{
while(c != ' ' && c != '\n' && c != '<' && c != '\t')
{
ch[cnt ++] = c;
c = getchar();
}
ch[cnt] = '\0';
cnt = 0;
ans.push_back(ch);
}
}
cnt = 0;
bool flag = false;
printf("Case #%d:\n", cas ++);
REP(i, ans.size())
{
if(ans[i][0] == '<')
{
flag = false;
if(ans[i][1] != '/')
{ REP(j, cnt) putchar(' ');
cout << ans[i] << endl;
int len = ans[i].size();
if(ans[i][len - 2] != '/') cnt ++;
else continue;
ch[0] = '<';
ch[1] = '/';
FF(j, 1, len)
{
if(ans[i][j] == ' ')
{
ch[j + 1] = '>';
ch[j + 2] = '\0';
break;
}
ch[j + 1] = ans[i][j];
}
ch[len + 1] = '\0';
}
else
{
cnt --;
REP(j, cnt) putchar(' ');
cout << ans[i] << endl;
}
}
else
{
if(!flag)
{
REP(j, cnt) putchar(' ');
cout << ans[i];
flag = true;
}
else cout << " " << ans[i];
if(ans[i + 1][0] == '<') puts("");
}
}
}
}

最新文章

  1. 30分钟让网站支持HTTPS
  2. ASP.NET-Web项目运行缓慢-AjaxMin在搞鬼
  3. 20145220&amp;20145209&amp;20145309信息安全系统设计基础实验报告(4)
  4. vc6.0运用mysql数据库中的编码所导致的乱码问题(接收和输出的编码必须要一致)
  5. 点击一个div隐藏另一个div
  6. XCode显示iOS Simulators时不显示系统版本号并出现Identifier(UUID)
  7. KMP算法 hdu4686 Oulipo
  8. PHP第三方登录 -- 微博登录
  9. 含有特殊字符的JSON串解析方法
  10. 【九度OJ】题目1201-二叉排序树
  11. Codeforces Round #276 (Div. 1) A. Bits 二进制 贪心
  12. 禁止Android的StatusBar下拉
  13. Xamarin Mono错误: unable to find explicit activity class
  14. golang Aes
  15. adxl345的STM32驱动程序和硬件设计
  16. C++实现Date日期类
  17. 李昊大佬的CV模板
  18. 用table绘制 等宽等间距的单元
  19. react-native-deprecated-custom-components
  20. ionic框架使用步骤

热门文章

  1. PCB成型製程介紹
  2. UBER人民优步司机注册攻略
  3. 12.04 如何更专业的使用Chrome开发者工具
  4. sql的强大功能(看一条sql解决的复杂业务)
  5. openstack 源码分析
  6. js柯里化的一个应用
  7. [01] Preparation - Sitecore Installment
  8. Create a custom configSection in web.config or app.config file
  9. JavaScript使用button提交表单
  10. java线程的使用(Runnable)