URAL/1094 E-screen(电子屏)

题目翻译链接:http://www.nocow.cn/index.php/Translate:URAL/1094

题意一直自己没理解。

View Code
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 using namespace std;
 5 int  i;
 6 int now;
 7 char a[100];
 8 char s[10010];
 9  
10 int main ()
11 {
12     for (i=0;i<80;i++)
13         a[i]=' ';
14     cin.getline (s,10010);
15     now=0;
16     for (i=0;i<strlen(s);i++)
17         {
18         if (s[i]=='<') {
19                        now--;
20                        if (now==-1) now=0;
21                        continue;
22                        }
23         if (s[i]=='>') {
24                        now++;
25                        if (now==80) now=0;
26                        continue;
27                        }
28         a[now]=s[i];
29         now++;
30         if (now==80) now=0;
31         }
32     for (i=0;i<80;i++)
33         cout<<a[i];
34     cout<<endl;
35     return 0;
36 }

 

posted @ 2012-04-27 17:08  我们一直在努力  阅读(165)  评论(0编辑  收藏  举报