ACM PKU 1028 Web Navigation 字符串数组处理

Source Code

Problem: 
1028  User: lnmm 
Memory: 176K  Time: 15MS 
Language: C
++  Result: Accepted 

Source Code 
#include
<iostream>
#include
<cstring>
using namespace std;

int main()
{
    
char temp[8],stack[255][255]={"http://www.acm.org/"};
    
int k=0,n;
    
while(cin>>temp)
    
{
        
if(temp[0]=='Q')
            
break;
        
else if(temp[0]=='V')
        
{
            k
++;
            cin
>>stack[k];
            cout
<<stack[k]<<endl;
            n
=k;
        }

        
else if(temp[0]=='B')
        
{
            k
--;
            
if(k<0)
            
{
                cout
<<"Ignored\n";
                k
=0;
            }

            
else
                cout
<<stack[k]<<endl;
        }

        
else
        
{
            k
++;
            
if(k>n)
            
{
                cout
<<"Ignored\n";
                k
=n;
            }

            
else
                cout
<<stack[k]<<endl;
        }

    }

    
return 0;
}


http://acm.pku.edu.cn/JudgeOnline/problem?id=1028

如果想用字符串,请记得
#include
<iostream>
#include<cstring>
using namespace std;

以避免不不要的麻烦.  (否则cin字符串的时候容易出错)

posted on 2007-11-06 18:09 流牛ζ木马 阅读(1052) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2007年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

导航

统计

公告

MY Email/MSN :mars1021@163.com QQ : 27402040 流牛ζ木马

常用链接

留言簿(6)

随笔档案

相册

搜索

最新随笔

最新评论

阅读排行榜

评论排行榜