//MiYu原创, 转帖请注明 : 转载自 ______________白白の屋

题目地址 :
      http://acm.hdu.edu.cn/showproblem.php?pid=1088
      模拟HTML 语言...............
标准的模拟题..............PE了好久, 终于A 了
代码如下 :
//MiYu原创, 转帖请注明 : 转载自 ______________白白の屋

#include<iostream>
#include 
<string>
using namespace std;
string hr = "--------------------------------------------------------------------------------";
int main()
{
    
string str, str1;
    
int count = 0;
    
while ( cin >> str )
    
{
        
int len = str.size ();
        
if ( str == "<br>" )
        
{
             cout 
<< endl;
             count 
=0;
        }

        
else if ( str == "<hr>" )
        
{
            
if ( count )
            
{
                 cout 
<< endl; 
            }

            cout 
<< hr << endl;
            count 
= 0;
        }

        
else
        
{
            
if ( count + len + 1 <= 80 ) 
            
{
                
if ( count )
                
{
                     cout 
<< " ";
                     count 
++;
                }

                cout 
<< str;
                count 
+= len;
            }

            
else
            
{
                cout 
<< endl;
                count 
= len;
                cout 
<< str;
            }

        }

    }

    cout 
<< endl;
    
return 0;
}

 posted on 2010-08-18 15:11  MiYu  阅读(266)  评论(0编辑  收藏  举报