below how solution should like.
enter y : 239847239
enter x : 847
x substring of y
enter y : 239847239
enter x : 3923
x subsequence of y
enter y : 239847239
enter x : 489
x neither substring nor subsequence of y
and below crude attempt @ making code:
int main() { cout << "enter y: "; vector <int> y; int y_number; cin >> y_number; cout << "enter x: "; vector <int> x; cin >> x; if (y > x) { for(int = 0; < y.size(); i++) { y.push_back(y_number); if (y.size(i) == x.size(i)) { } } } else { cout << "x neither substring nor subsequence of y"; } }
maybe want:
#include <iostream> #include <string> using namespace std; int main() { string y, x, yy; cout << "enter y: "; cin >> y; cout << "enter x: "; cin >> x; yy = y + y; if (std::string::npos != y.find(x)) { cout << "x substring of y" << endl; } else if (std::string::npos != yy.find(x)) { cout << "x subsequence of y" << endl; } else { cout << "x neither substring nor subsequence of y" << endl; } return 0; }
update: @ least generates same results description.
Comments
Post a Comment