码迷,mamicode.com
首页 > 其他好文 > 详细

HDUOJ Train Problem I

时间:2015-08-02 10:16:49      阅读:141      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!