// test13.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
vector<int> longNum;
vector<int> shortNum;
int num,flag=1;
cout << "请输入长序列:" << endl;
while (cin >> num)
{
longNum.push_back(num);
if (getchar() == '
')
break;
}
cout << "请输入短序列:" << endl;
while (cin >> num)
{
shortNum.push_back(num);
if (getchar() == '
')
break;
}
for (auto it = longNum.begin(); it != longNum.end(); it++)
{
cout << *it << " ";
}cout << endl;
for (auto it = shortNum.begin(); it != shortNum.end(); it++)
{
cout << *it << " " ;
}cout << endl;
for (int i = 0; i < shortNum.size(); i++)
{
if (shortNum[i] != longNum[i])
{
flag = 0;
break;
}
}
if (flag == 1)
cout << "短序列是长序列的前缀" << endl;
else
cout << "短序列不是长序列的前缀" << endl;
}