HDU 1088 - Write a simple HTML Browser

直接看sample input = =

又一道模拟。

 1 #include <iostream>
 2 #include <string>
 3 #include <cstdio>
 4 using namespace std;
 5 string s;
 6 int main()
 7 {
 8 //    freopen("date.out","w",stdout);
 9     int m=0;
10     while(cin>>s)
11     {
12         if(s=="<br>")
13         {
14             cout<<endl;
15             m=0;
16         }
17         else if(s=="<hr>")
18         {
19             if(m!=0)
20             {
21                 cout<<endl;
22                 m=0;
23             }
24             cout<<string(80,‘-‘)<<endl;
25         }
26         else
27         {
28             if(m+s.length()+1>80)
29             {
30                 cout<<endl;
31                 m=0;
32             }
33             if(m)
34             {
35                 cout<<‘ ‘;
36                 m++;
37             }
38             cout<<s;
39             m+=s.length();
40             if(m>=80)
41             {
42                 cout<<endl;
43                 m=0;
44             }
45         }
46     }
47     cout<<endl;
48 }
时间: 2024-08-02 22:49:43

HDU 1088 - Write a simple HTML Browser的相关文章

HDU ACM 1088 Write a simple HTML Browser

题意:出现<br>换行,出现<hr>输出'-',每一行的加上现在的单词如果长度超过80则换行,每个单词前留一个空格,结束时要输出换行. #include<iostream> using namespace std; int main() { char s[100]; int len,cnt=0; while(scanf("%s",s)==1) { if(!strcmp(s,"<br>")) { cnt=0; putch

hdu 5349 MZL&#39;s simple problem

Problem Description A simple problem Problem Description You have a multiple set,and now there are three kinds of operations: 1 x : add number x to set 2 : delete the minimum number (if the set is empty now,then ignore it) 3 : query the maximum numbe

【multiset】hdu 5349 MZL&#39;s simple problem

[multiset]hdu 5349 MZL's simple problem 题目链接:hdu 5349 MZL's simple problem 题目大意 n次操作,插入元素.删除最小元素.查询最大元素并输出. C++STL的multiset的使用 set--多元集合(元素不可重复),multiset--可重复元素的多元集合 多元集合(MultiSets)和集合(Sets)相像,只不过支持重复对象.(具体用法请参照set容器) set和multiset内部是以平衡二叉树实现的: 从内部数据结

hdu 5349 MZL&#39;s simple problem(multiset)

代码: #include<set> #include<cstdio> using namespace std; multiset<int> st; int main() { int n; multiset<int>::iterator it; while(scanf("%d",&n)==1) { st.clear(); int k,num; for(int i=0; i<n; i++) { scanf("%d&qu

hdu 1088 滑雪

果然书要结合题来看才有效果 通过这题对记忆化搜索有了初步的理解 碰到没有访问过的点 进行搜索 之后记录下该点能滑出的最远距离 碰到搜索过的点 直接加上 dp[i] 就可以了 #include<stdio.h> #include<string.h> #include<math.h> #include<iostream> #include<algorithm> #include<queue> #include<stack> #

HDOJ1088 Write a simple HTML Browser 【simulation】

Write a simple HTML Browser Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6917    Accepted Submission(s): 1853 Problem Description If you ever tried to read a html document on a Macintosh, yo

hdu - 5349 MZL&#39;s simple problem(解题报告)

A - MZL's simple problem Time Limit:1500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description A simple problem Problem Description You have a multiple set,and now there are three kinds of operations: 1 x : add number

HDU1088 Write a simple HTML Browser【字符串处理】【水题】

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, yo

HDU 5349 MZL&#39;s simple problem(优先队列)

MZL's simple problem Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 776    Accepted Submission(s): 375 Problem Description A simple problem Problem Description You have a multiple set,and now