-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQ5.cpp
More file actions
68 lines (65 loc) · 1.18 KB
/
Q5.cpp
File metadata and controls
68 lines (65 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using namespace std;
#include<string>
#include<iostream>
#include<vector>
bool check_subsequence(vector<string> A,vector<string> B)
{
int m=A.size();
int n=B.size();
if(m<n)
return false;
int i=0;
int j=0;
while(i<m&&j<n)
{
if(!B[j].compare(A[i]))
{
i++;
j++;
}
else
i++;
}
if (j==n)
{
return 1;
}
else
return 0;
}
int main()
{
vector<string> a;
vector<string> b;
cout<<"Enter events A:";
bool acontinue=true;
do
{
string atemp;
getline(cin,atemp);
if(!atemp.compare("exit"))//type exit to stop
{
acontinue=false;
}
else
a.push_back(atemp);
}while(acontinue);
cout<<"Enter events B:";
bool bcontinue=true;
do
{
string btemp;
getline(cin,btemp);
if(!btemp.compare("exit"))
{
bcontinue=false;
}
else
b.push_back(btemp);
}while(bcontinue);
if(check_subsequence(a,b))
cout<<"\nyes,list of events b is a subsequence of events b";
else
cout<<"no";
return 0;
}