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

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字符串的时候容易出错)

你可能感兴趣的:(ACM PKU 1028 Web Navigation 字符串数组处理)