标题:帮忙看看,大神们。主要是交到oj上市wa ;
只看楼主
swustxf
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-4-7
 问题点数:0 回复次数:0 
帮忙看看,大神们。主要是交到oj上市wa ;
#include <iostream>
#include <malloc.h>
using namespace std ;
#define maxsize 1001

struct stack
{
                char data[maxsize] ;
                int top ;
};


bool push(stack  *&s , char e)
{
      if(s->top == maxsize-1)
                return false ;
      s->top++ ;
      s->data[s->top] = e ;
      return true ;
}

char pop(stack *&s)
{
                char e ;
                e = s->data[s->top] ;
                s->top-- ;
                return e;
}

int main()
{
                stack *s  = new stack ;
                s->top = -1 ;
                char str1[101] ,str2[101];
                int i = 0 ;
                bool flag = 0;
                while(true)
                {
                                cin>>str1[i] ;
                                if(str1[i] == '@')
                                                break ;
                                i++;
                }
                int m ;
                for(m = 0 ;m<i ;m++)
                       push(s,str1[m]);
                int j = 0 ;
                while(true)
                {
                      char e = pop(s) ;
                                cin>>str2[j] ;
                                if(str2[j] == e)
                                    flag = 1;
                                if(str2[j] == '#')
                                                break ;
                                j++;
                }
                if(flag == 1)
                    cout<<"yes!" ;
                else
                    cout<<"no!" ;
                return 0 ;

}

编写一程序,识别依次读入的一个以“#”为结束符的字符序列是否为形如“序列1@序列2”模式的字符序列。期中序列1和序列2中都不含字符“@”,且序列2是序列1的逆序列。例如“a+b@b+a”是满足条件的序列字符,而“1+3@3-1”则不是。
搜索更多相关主题的帖子: include return false 
2015-04-21 14:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-444332-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.212684 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved