Topic Links:
http://acm.hdu.edu.cn/showproblem.php?pid=1088
Topic Type:
Simple simulation of strings
Test Instructions Summary:
For a bunch of strings given, when encountering <br> wrapping, encountering
Problem Solving Ideas:
According to test instructions simulation can be.
Topic:
Write a simple HTML Browser
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 12093 Accepted Submission (s): 3497
Problem descriptionif you ever tried to read a HTML document on a Macintosh, you know how hard it was if no Netscape is INS Talled.
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 Inputhallo, Dies ist eine Ziemlich lange Zeile, die in Htmlaber nicht umgebrochen wird.<br>zwei <br> &l T;br> Produzieren zwei newlines. Es gibt auch noch das tag
Sample Outputhallo, 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.
# include <stdio.h># include<string.h>intMain () {intl,ret=0; Chara[ the]; while(SCANF ("%s", a)! =EOF) { if(a[0]=='<'&&a[1]=='b'&&a[2]=='R'&&a[3]=='>') {printf ("\ n"); RET=0; Continue; } if(a[0]=='<'&&a[1]=='h'&&a[2]=='R'&&a[3]=='>') { if(ret!=0) printf ("\ n"); printf ("--------------------------------------------------------------------------------\ n"); RET=0; Continue; } l=strlen (a); if(ret==0) {printf ("%s", a); RET+=l; Continue; } if(ret+l+1<= the) {printf ("%s", a); RET+=l+1; } Else if(ret+1+l> the) {printf ("\ n", ret); printf ("%s", a); RET=l; }} printf ("\ n"); return 0;}
hdu-1088 Write a simple HTML Browser