Posted on 2008-03-28 22:43
superman 阅读(451)
评论(1) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1099 C++ 00:00.00 840K */
2 #include <string>
3 #include <iostream>
4
5 using namespace std;
6
7 int main()
8 {
9 string word;
10 int curLineLen = 0;
11
12 while(cin >> word)
13 {
14 if(word == "<br>")
15 {
16 curLineLen = 0;
17 cout << endl;
18 continue;
19 }
20 if(word == "<hr>")
21 {
22 if(curLineLen)
23 cout << endl;
24 for(int i = 0; i < 80; i++)
25 cout << '-';
26 cout << endl;
27 curLineLen = 0;
28 continue;
29 }
30 if(curLineLen == 0)
31 {
32 curLineLen = word.size();
33 cout << word;
34 continue;
35 }
36 if(curLineLen + word.size() + 1 <= 80)
37 {
38 if(curLineLen)
39 cout << ' ';
40 cout << word;
41 curLineLen += word.size() + 1;
42 }
43 else
44 {
45 curLineLen = word.size();
46 cout << endl;
47 cout << word;
48 }
49 }
50 cout << endl;
51
52 return 0;
53 }
54