首页 > 其他 > 详细

HDUOJ Train Problem I

时间:2015-08-02 10:14:48      阅读:240      评论:0      收藏:0      [点我收藏+]

#include<stdio.h>
#include<string.h>
#include<stack>
using namespace std;
stack<char> str;
char s1[9],s2[9];
int main()
{
 int n;
 str.push(‘#‘);
 while(~scanf("%d %s %s",&n,s1,s2))
 {
  while(str.top()!=‘#‘)
   str.pop();
  int l=0,i;
  for(i=0;i<n;i++)
  {
    str.push(s1[i]);
          if(str.top()==s2[l])
          {
          while(str.top()==s2[l])
          {
           str.pop();
           l++;
          }
          }
     }
  if(str.top()==‘#‘)
  {
   printf("Yes.\n");
   l=0;
   for(i=0;i<n;i++)
   {
    if(str.top()!=s2[l])
    {
     str.push(s1[i]);
     printf("in\n");
           if(str.top()==s2[l])
           {
          while(str.top()==s2[l])
          {
           str.pop();
           printf("out\n");
           l++;
          }
           }
    }
      }
      printf("FINISH\n");
     }
  else printf("No.\nFINISH\n");  
 }
 return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

HDUOJ Train Problem I

原文:http://blog.csdn.net/yueloveme/article/details/47204613

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!