美文网首页
1138 Postorder Traversal(25 分)

1138 Postorder Traversal(25 分)

作者: zjh3029 | 来源:发表于2018-08-13 23:05 被阅读0次
#include <iostream>
#include <vector>
#include<string>
#include <algorithm>
using namespace std;


int main()
{
    int M,a;
    vector<int> v1, v2;
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> a;
        v1.push_back(a);
    }
    for (int i = 0; i < M; i++)
    {
        cin >> a;
        v2.push_back(a);
    }

    vector<int>::iterator it,it2=v2.end();
    for (auto c : v1)
    {
        it=find(v2.begin(), v2.end(), c);
        if (it==v2.begin())
        {
            if (it==it2-1)
            {
                cout << *it << endl;
            }
            else
            {
                cout <<  *(it+1) << endl;
            }
            break;
        }
        it2 = it;
    }

    system("pause");
    return 0;
}

相关文章

网友评论

      本文标题:1138 Postorder Traversal(25 分)

      本文链接:https://www.haomeiwen.com/subject/ouvpbftx.html