HDU1088 Write A simple HTML Browser "string handling" "Water problem"

Source: Internet
Author: User
Tags strcmp

Write A simple HTML Browser

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total Submission (s): 8533 Accepted Submission (s): 2402
Problem Description
If you ever tried to read a HTML document on a Macintosh, you know how hard it is if no Netscape is installed.
Now, who can forget to install a HTML browser? This was very easy because most of the times you don't need one on a MAC because there are a acrobate Reader which is native To MAC. But if you ever need one and what does?
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 linebre AK and
Input
The input consists of a text you should display. This text consists of words and HTML tags separated by one or more spaces, tabulators or newlines.
A word is a sequence of letters, numbers and punctuation. For example, "abc,123" was one word, but "ABC, 123" was the words, namely "ABC," and "123". A word is always shorter than bayi characters and does not contain any ' < ' or ' > '. All HTML tags is either <br> or
Output
You should display the resulting text using this rules:
. If you read a word in the input and the resulting line does not get longer than chars, print it, else print it on a new Line.
. If you read a <br> with the input, start a new line.
. If you read a The last line was ended by a newline character.

Sample Input
Hallo, Dies ist eine
Ziemlich lange Zeile, die in Html
Aber nicht umgebrochen wird.
<br>
Zwei <br> <br> produzieren Zwei newlines.
Es gibt auch noch das tag Zwei Achtung Mehrere Leerzeichen Irritieren

Html Genauso Wenig wie


Mehrere Leerzeilen.

Sample Output
Hallo, Dies ist eine Ziemlich lange Zeile, die in Html aber nicht umgebrochen
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.

Source

University of Ulm Local Contest 1999


Main topic: Enter a piece of HTML text, and then according to the input text, according to the HTML language format output

Out, but each line cannot exceed 80 characters, and the output will be wrapped in a newline.

Note: Encounter <br> will change line, encounter enter 80 '-' in the next line.

Idea: The first time to do while reading the side output, just started PE two times, changed the AC. And then I feel like this

Input and output no aesthetic ... So I changed it into a large string and then output it.

That's a lot more beautiful. (ーー゛) ...

First pass side input side output:

#include <iostream> #include <algorithm> #include <cstdio> #include <cstring>using namespace    Std;char S[110];int Main () {int Count = 0;            while (Cin >> s) {if (strcmp (S, "<br>") = = 0) {cout << Endl;            Count = 0;        Continue                } if (strcmp (S, "
First enter the storage and re-output:

#include <iostream> #include <algorithm> #include <cstdio> #include <cstring>using namespace    Std;char S[110];char A[10010];int Main () {int Count = 0;    int id = 0;            while (Cin >> s) {if (strcmp (S, "<br>") = = 0) {a[id++] = ' \ n ';            Count = 0;        Continue                } if (strcmp (S, "


HDU1088 Write A simple HTML Browser "string handling" "Water problem"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.