Im_hear

导航

zoj 1099

View Code
 1 #pragma warning (disable:4786)
 2 #include <cstdio>
 3 #include <iostream>
 4 #include <algorithm>
 5 using namespace std;
 6 #include <cstring>
 7 
 8 int main()
 9 {    
10     //freopen("in.txt","r",stdin);
11     //freopen("out.txt","w",stdout);
12     char str[100];
13     int length = 0;
14     bool begin = true;
15     while(scanf("%s",str) != EOF){
16         if(str[0] == '<' && str[1] == 'b'){
17             begin = true;
18             length = 0;
19             printf("\n");            
20         }
21         else if(str[0] == '<' && str[1] == 'h'){
22             if(!begin)printf("\n");
23             for(int i=0; i < 80; ++i)printf("-");            
24             printf("\n");
25             begin = true;            
26             length = 0;
27         }
28         else{
29             if(begin){
30                 printf("%s",str);
31                 length = strlen(str);
32                 begin = false;
33             }
34             else if(length + strlen(str) + 1 > 80){
35                 printf("\n%s",str);
36                 length = strlen(str);
37                 begin = false;
38             }
39             else {
40                 printf(" %s",str);
41                 length += strlen(str) + 1; 
42                 begin = false;
43             }
44         }
45     }
46     return 0;
47 }

posted on 2012-04-26 09:09  Im_hear  阅读(155)  评论(0编辑  收藏  举报