hdu-1088 Write a simple HTML Browser

Source: Internet
Author: User

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 Inputthe 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 Outputyou should display the 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 Htmlaber nicht umgebrochen wird.<br>zwei <br> <br> Pro Duzieren zwei newlines. Es gibt auch noch das tag 

Sample Output

 Hallo, Dies ist eine Ziemlich lange Zeile, die in Html aber nicht umgebrochenwird. Zweiproduzieren zwei newlines. Es gibt auch noch das tag--------------------------------------------------------------------------------was einen Trenner darstellt. Zwei--------------------------------------------------------------------------------------------------------------------- -------------------------------------------Produzieren zwei Horizontal Rulers. Achtung mehrere Leerzeichen irritieren htmlgenauso wenig wie mehrere Leerzeilen. 

This is a simulation problem, but the surface has a few small pits, I was wrong 4 times to all change over, changed the code is beyond recognition??
#include <cstdio> #include <cstring> #include <algorithm> #include <iostream>using namespace    Std;int Main () {int len=0;    string S;   while (cin>>s) {//cout<<s<<endl;  Len+=s.length ();        cout<<len<<endl;            if (s[0]== ' < ') {if (s[1]== ' B ') cout<<endl;                else{if (len<80&&len>0) cout<<endl;                for (int i=1;i<=80;i++) cout<< "-";            cout<<endl;        } len=0;            } else{len+=s.length ();            if (len>=80) {cout<<endl<<s;            Len=s.length ();            } else if (Len==s.length ()) cout<<s;                else {len++;            cout<< "" <<s;    }} s= "";    } cout<<endl; return 0;}

  

hdu-1088 Write a simple HTML Browser

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.