【字符串】HDU1088Write a simple HTML Browser

来源:互联网 发布:黑人 知乎 编辑:程序博客网 时间:2024/06/01 10:25

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1088

#include<bits/stdc++.h>using namespace std;int main(){//    freopen("test.txt","r",stdin);    string s;    string ans="";    int len=0;    while(cin>>s){        if(s=="<br>"){            cout<<endl;            len=0;        }else if(s=="<hr>"){            if(len) cout<<endl;            cout<<"--------------------------------------------------------------------------------"<<endl;            len=0;        }else{            if(s.size()+len+1<=80){                if(len) cout<<' '<<s,len++;                else cout<<s;                len+=s.size();            }else{                len=s.size();                cout<<endl<<s;            }        }    }    cout<<endl;    return 0;}