水题:HDU-1088-Write a simple HTML Browser(模拟题)
Now, who can forget to install a HTML browser? This is very easy because most of the times you don't need one on a MAC because there is a Acrobate Reader which is native to MAC. But if you ever need one, what do you do?
Your task is to write a small html-browser. It should only display the content of the input-file and knows only the html commands (tags) <br> which is a linebreak and <hr> which is a horizontal ruler. Then you should treat all tabulators, spaces and newlines
as one space and display the resulting text with no more than 80 characters on a line.
A word is a sequence of letters, numbers and punctuation. For example, "abc,123" is one word, but "abc, 123" are two words, namely "abc," and "123". A word is always shorter than 81 characters and does not contain any '<' or '>'. All HTML tags are either <br>
or <hr>.
. If you read a word in the input and the resulting line does not get longer than 80 chars, print it, else print it on a new line.
. If you read a <br> in the input, start a new line.
. If you read a <hr> in the input, start a new line unless you already are at the beginning of a line, display 80 characters of '-' and start a new line (again).
The last line is ended by a newline character.
ziemlich lange Zeile, die in Html
aber nicht umgebrochen wird.
<br>
Zwei <br> <br> produzieren zwei Newlines.
Es gibt auch noch das tag <hr> was einen Trenner darstellt.
Zwei <hr> <hr> produzieren zwei Horizontal Rulers.
Achtung mehrere Leerzeichen irritieren
Html genauso wenig wie
mehrere Leerzeilen.
wird.
Zwei
produzieren zwei Newlines. Es gibt auch noch das tag
--------------------------------------------------------------------------------
was einen Trenner darstellt. Zwei
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
produzieren zwei Horizontal Rulers. Achtung mehrere Leerzeichen irritieren Html
genauso wenig wie mehrere Leerzeilen.
#include<stdio.h>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
bool first = false;
//FILE *f;//注意使用文件指针
char a[90];
int leng = 0;
//f = fopen("new.txt","w");//文件指针会自动向下转移不用手动
while(~scanf("%s",a))
{
if(strcmp(a,"<br>") == 0)//c语言中可这样判别两个字符串是否一样,如果一样会返回0;
{
first = true;
printf("\n");
//fprintf(f,"%c",10);
leng = 0;
continue;
} if(strcmp(a,"<hr>") == 0)
{
if(leng != 0)//连续两个<br>要注意有没有多余的空行。
{
printf("\n");
//fprintf(f,"%c",10);
first = true;
}
printf("--------------------------------------------------------------------------------\n");
//fprintf(f,"%s","--------------------------------------------------------------------------------");
//fprintf(f,"%c",10);
leng = 0;
first = true;
continue;
}
else
{
if(leng == 0)
{
first = false;
printf("%s",a);
leng += strlen(a);
//for(int i=0;i<strlen(a);i++)
//fprintf(f,"%c",a[i]);
}
else if((leng+strlen(a)+1)<=80)
{
printf(" %s",a);
//fprintf(f,"%c",32);
//for(int i=0;i<strlen(a);i++)
//fprintf(f,"%c",a[i]);
leng = strlen(a) + 1 + leng;//这里+1是因为有空格;
}
else
{
printf("\n%s",a);
//fprintf(f,"%c",10);
//for(int i=0;i<strlen(a);i++)
//fprintf(f,"%c",a[i]);
leng = strlen(a);
first = false;
}
}
}
if(!first)//要有一个新的空行,不然PE;
printf("\n");
//fclose(f);//文件指针最后要关闭
return 0;
}
水题:HDU-1088-Write a simple HTML Browser(模拟题)的更多相关文章
- HDU 1088 Write a simple HTML Browser 有点恶心的字符串题
这题是从某个群里听别人在抱怨这题老是PE,打开status果然满眼的Presentation Error...于是闲着来做了一下. 其实挺水的,不过各种设定多一点,注意一点就行了. 一开始以为词数超过 ...
- HDOJ/HDU 1088 Write a simple HTML Browser(HTML字符串)
Problem Description If you ever tried to read a html document on a Macintosh, you know how hard it i ...
- HDU 1088 - Write a simple HTML Browser
直接看sample input = = 又一道模拟. #include <iostream> #include <string> #include <cstdio> ...
- hdu 5641 King's Phone(暴力模拟题)
Problem Description In a military parade, the King sees lots of new things, including an Andriod Pho ...
- HDU ACM 1088 Write a simple HTML Browser
意甲冠军:出现<br>总结,出现<hr>出口'-',今天的字加上各行的假设是长于80然后包,每个字之前,留下一个空白格,为了输出新行结束. #include<iostre ...
- hdu 2629 Identity Card (字符串解析模拟题)
这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿; 题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了: http://acm.hdu.edu.cn/showproblem.ph ...
- 【HDOJ】1088 Write a simple HTML Browser
题目其实不难,但是要注意题目的要求,当前字数(>0)+当前单词长度+1若超过80则需要回车后,输出当前word,并且重新计数.这道题目的数据感觉比较水,不过测试的时候,最后使用fprintf输出 ...
- hdu 5083 Instruction (稍比较复杂的模拟题)
题意: 二进制指令转汇编指令,汇编指令转二进制指令. 思路: 额,条理分好,想全,思维不能乱. 代码: int findyu(char yu[50],char c){ int l=strlen(yu) ...
- poj1472[模拟题]
Instant Complexity Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2017 Accepted: 698 ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
随机推荐
- java打印堆栈信息
StackTraceElement[] stackElements = new Throwable().getStackTrace(); if(stackElements != null){ for( ...
- C#数字图像处理算法学习笔记(一)--C#图像处理的3中方法
C#数字图像处理算法学习笔记(一)--C#图像处理的3中方法 Bitmap类:此类封装了GDI+中的一个位图,次位图有图形图像及其属性的像素数据组成.因此此类是用于处理像素数据定义的图形的对象.该类的 ...
- gitk更改主题设置打不开
➜ project git:(master) gitk Error in startup script: unknown color name "lime" (processing ...
- vue-pos : 子组件与子组件通讯
子组件与子组件通讯: 例子子组件1 要与子组件2 通讯 步骤1 : 在父组件新建一个 vue 对象 : const eventHub = new Vue() 步骤2 : 子组件1 发起事件 :this ...
- >>我要到处浪系列 之 JS随便投票小脚本
首先郑重声明:我不是对任何网站或者任何个人或组织有意见,仅仅是觉得 4点几 的评分对某些玩票的片段都太高了,为了落实想法,切实履行公民的投票权,并且 bibibabibobi biubiubiu..所 ...
- php 04
前加加(++$a) 先运算后赋值 后加加($a++) 先赋值后运算 -- 前减减(--$a) 先运算后赋值 后减减($a--) 先赋值后运算 连接运算符(字符串运算符) . 神奇的米粒 1. 字符串和 ...
- java网络编程—TCP(1)
演示tcp的传输的客户端和服务端的互访. 需求:客户端给服务端发送数据,服务端收到后,给客户端反馈信息. 客户端: 1,建立socket服务.指定要连接主机和端口. 2,获取socket流中的输出流. ...
- linux中BASH_SOURCE[0](转)
转自:http://www.cnblogs.com/sunfie/p/5943979.html 在C/C++中,__FUNCTION__常量记录当前函数的名称.有时候,在日志输出的时候包含这些信息是非 ...
- Array负载均衡控制器(vAPV)
平台: freebsd 类型: 虚拟机镜像 软件包: apache python basic software load balance network infrastructure slb ssl ...
- ArcGIS10.1的安装问题
注:必须用3个带0的文件夹里面的东西安装 1.先装Pre-release_license_manager ,然后停掉. 2.然后安装0Desktop/ArcGIS_Desktop, 3.打开0Ke ...