题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1099
这道题挺烦人的, 主要是细节的东西太多, 一不注意就容易载进去
而且我发现, 就地下 if(first + str.length() >= max )
你要是写成 if(first + str.length() + 1 >= max ) 也Accepted
一行长度不能超过80, 注意
#include "iostream"
#include "string"
using namespace std;
#define max 80
int main(){
string str;
int first = 0;
while( cin >> str ){
if( str == "<br>"){
cout<<endl;
first = 0;
}
else if( str == "<hr>"){
if(first)
cout<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;
first = 0;
}
else{
if( first + str.length() >= max ){
cout<<endl;
first = 0;
}
if(first){
cout<<" ";
++first;
}
cout<<str;
first += str.length();
}
}
return 0;
}