模拟专题

https://vjudge.net/contest/270198

突然想试试这个有毒的东西。


A - HTML

第一次做模拟,先试试。

1.<br>规定为:换行。

2.<hr>规定为:假如现在不是新行,则换行。然后输出一个80字符的分隔线,最后换行。

3.空格/换行规定为:空格。

4.每行不得超过80个字符,一个单词不能断开。

5.最后一行要换行。

感觉有歧义,因为没说假如最后一行本身是空行还要不要换行?那就先当他要换。

 

AC了,还是挺简单的。

//#include<bits/stdc++.h>
#include<string>
#include<iostream>
using namespace std;

string hr;

string s;
string cur;

//bool newline=1;

int main(){
    for(int i=0;i<80;i++)
        hr+='-';

#ifdef Yinku
    freopen("Codeforces.in","r",stdin);
    freopen("Codeforces.out","w",stdout);
#endif // Yinku

    while(cin>>s){
        if(s=="<br>"){
            cout<<cur<<endl;
            cur="";
        }
        else if(s=="<hr>"){
            if(cur!=""){
                cout<<cur<<endl;
                cur="";
            }
            cout<<hr<<endl;
        }
        else{
            if(cur!=""){
                if(cur.length()+1+s.length()<=80){
                    s=" "+s;
                    cur+=s;
                }
                else{
                    cout<<cur<<endl;
                    cur=s;
                }
            }
            else{
                cur+=s;
            }
        }
    }
    cout<<cur<<endl;
}
View Code

 

转载于:https://www.cnblogs.com/Yinku/p/10498901.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值