zoukankan      html  css  js  c++  java
  • nyoj-150-Train Problem I

     
    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    #include<math.h>
    #include<stack>
    using namespace std;
    int main()
    {
        stack<char> s1;
        int n,i,wet[50];
        char a1[25],a2[25];
        while(scanf("%d",&n)!=EOF)
        {
            scanf("%s%s",a1,a2);
            memset(wet,0,sizeof(wet));
            int flag=0,temp=0;
            for(i=0;i<n;i++)
            {
                s1.push(a1[i]);
                wet[temp++]=1;
                while(!s1.empty()&&flag<n&&s1.top()==a2[flag])
                {
                    s1.pop();
                    wet[temp++]=2;
                    flag++;
                }
            }
            if(flag==n)
            {
                printf("Yes.
    ");
                for(int j=0;j<temp;j++)     
                {
                    if(wet[j]==1)
                    printf("in
    ");
                    if(wet[j]==2)
                    printf("out
    ");
                }
            }
            else
            printf("No.
    ");
            printf("FINISH
    ");
        }
        return 0;
    }
            

    这个题的数据有特殊的  比如   进去的大于n个   但是只要出来的是目标就可以  

  • 相关阅读:
    python之基础2
    python之文件2
    python之入门2
    python之入门
    python之多并发2
    python之面向对象2
    python之MySQL系列
    python之文件
    python之多并发
    Google身份验证器详解
  • 原文地址:https://www.cnblogs.com/nylg-haozi/p/3208873.html
Copyright © 2011-2022 走看看