这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
题目地址:
http://acm.hdu.edu.cn/showproblem.php?pid=1088
汗。刚开始一直PE。 原来把输出空格放到最前面,导致换行时也输出了空格。。。
// Author: Tanky Woo
// HDOJ 1088
// Accepted 1088 0MS 232K 785 B C++ Tanky Woo
#include
#include
using namespace std;
string hr = "--------------------------------------------------------------------------------";
int main()
{
string str;
int cnt = 0;
while(cin >> str)
{
if(str == "
")
{
cout << endl;
cnt = 0;
}
else if(str == "
* * *
")
{
if(cnt)
cout << endl;
cout << hr << endl; cnt = 0; } else { int len = str.size(); if(cnt+len>80)
{
cnt=0;
cout << endl;
}
if(cnt)
cout << " " << str;
else
cout << str;
cnt += len+1;
}
}
cout << endl;
return 0;
}