hdu Write a simple HTML Browser

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1088

 

对比输出

 

代码:

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <math.h>
 4 #include <algorithm>
 5 #include <iostream>
 6 #include <ctype.h>
 7 #include <iomanip>
 8 #include <queue>
 9 #include <map>
10 #include <stdlib.h>
11 using namespace std;
12 
13 char word[81];
14 
15 int main()
16 {
17     int len,i;
18     int cp=-1;
19     while(scanf("%s",word)==1){
20         if(strcmp(word,"<br>")==0){
21             putchar('\n');
22             cp=-1;
23         }
24         else if(strcmp(word,"<hr>")==0){
25             if(cp!=-1)
26                 putchar('\n');
27             for(i=0;i<80;i++)
28                 putchar('-');
29             putchar('\n');
30             cp=-1;
31         }
32         else{
33             len=strlen(word);
34             if(cp+len+1<80){
35                 if(cp!=-1)
36                     putchar(' ');
37                 printf("%s",word);
38                 cp+=(len+1);
39             }
40             else{
41                 putchar('\n');
42                 printf("%s",word);
43                 cp=len;
44             }
45         }
46     }
47     putchar('\n');
48     return 0;
49 }
View Code

 

posted @ 2015-10-12 15:51  Vmetrio  阅读(231)  评论(0)    收藏  举报