1. 程式人生 > >uva-10340-水題

uva-10340-水題

題意:字串匹配,看樣例輸入理解題意

 

直接迴圈

#include <string>
#include<iostream>
#include<map>
#include<memory.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<math.h>
#include<iomanip>


namespace
cc { using std::cout; using std::endl; using std::cin; using std::map; using std::vector; using std::string; using std::sort; using std::priority_queue; using std::greater; using std::vector; using std::swap; using std::stack; constexpr
double MD = 1e-6; void solve() { string str1, str2; while (cin>>str1>>str2) { int ok = 0; for (int i=0;i<str2.length();i++) { if (str2[i] == str1[0]) {
int k = 1; for (int j=i+1;j<str2.length()&&k<str1.length();j++) { if (str2[j] == str1[k]) ++k; } if (k == str1.length()) { ok = 1; break; } } } if (ok) cout << "Yes" << endl; else cout << "No" << endl; } } }; int main() { #ifndef ONLINE_JUDGE freopen("d://1.text", "r", stdin); #endif // !ONLINE_JUDGE cc::solve(); return 0; }