RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
小代码栈之合法性一点思路不一样的际遇
/************
1 2 3 4 如栈
出栈 
3 2 4 1 返回0
错误 3 1 2 4 返回-1
**********/
#include
#include
#include

using namespace std;

bool judge(const char *push_seq, const char *pop_seq)
{
    if (NULL == push_seq || NULL == pop_seq)
    {
        return false;         
    }
    if (strlen(push_seq) != strlen(pop_seq))
    {
        return false;
    }
   
    stacksc;
    while (*push_seq)
    {
        if (0 == sc.size() || sc.top() != *pop_seq)
        { 
            sc.push(*push_seq++); //
        }
        else
        { 
            sc.pop();
            ++pop_seq; //
        }
    }
    while (sc.size())
    {
        if (sc.top() != *pop_seq++)
        {
            return false;
        }
        sc.pop();
    }
    
    return true;
}  
int mycheck1(int a[],int n)
{
    stacks;
    int i,j,k=1;          // 3 2 4 1
    for(i=0;ik)
          { for(j=k;js;      s.push(0);
    int i,j,k=1;         //BUG段  经过分析 在于s.top段  因为没有元素时这样做有越界的含义
    for(i=0;ik)
          { for(j=k;j            
            
                                                            
网页标题:小代码栈之合法性一点思路不一样的际遇
当前链接:http://cqwzjz.cn/article/jdsscg.html