比这篇新的文章: Codee#2611
比这篇旧的文章: Codee#2609

Codee#2610 编辑代码

语言: C++, 标签: 无  2009/07/02发布 8个月前更新 | 编辑代码
作者: , 点击69次, 评论(0), 收藏者(0), , 打分:

背景
主题: 字体:
C++语言: Codee#2610
01 #include<iostream>
02 #include<string>
03 using namespace std;
04
05 int main()
06 {
07     freopen("BAIDU.html","w",stdout);
08     char c;
09     string s;
10     bool b=0,tu=0,once=1;
11     int ans=0;
12     while((c=getchar())!=EOF)
13     {
14         if(c=='>')
15         {
16             s+='>';
17             b=0;
18             if(s=="</DIV>")
19                 ans++;
20
21             if(tu)
22             {
23                 if(s[1]=='D'&&s[2]=='I'&&s[3]=='V')
24                     ans++;
25             }
26
27             if(ans==1)
28                 tu=1;
29             else if(ans==2)
30             {
31                 cout<<s;
32                 if(once)
33                 {
34                     once=0;
35                     cout<<"<html><body><basefont face=\"Fixedsys\">";
36                 }
37             }
38             else if(ans==3)
39             {
40                 cout<<"</body></html>"<<s<<endl;
41                 break;
42             }
43
44         }
45
46         if(b)
47         {
48             s+=c;
49         }
50         else if(tu&&c!='<'&&c!='>')
51         {
52             cout<<c;
53         }
54
55         if(c=='<')
56         {
57             b=1;
58             s="<";
59         }
60     }
61     return 0;
62 }


所有评论,共0条:( 我也来说两句)


发表评论

注册登录后再发表评论