标签:blog io os sp div log bs amp as
//模拟字符串定位函数 // s: abcbbghi // t: ghi // 返回6 #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string s, t; int len1, len2; int i, j; while(cin>>s) { cin>>t; len1=s.size(); len2=t.size(); i=0; j=0; while(i<len1 && j<len2 ) { if(s[i]==t[j]) { i++; j++; } else { i=i-j+1; j=0; } } if(j>=len2) { cout<<i-j+1<<endl; } else { cout<<"No\n"; } } return 0; }
标签:blog io os sp div log bs amp as
原文地址:http://www.cnblogs.com/yspworld/p/4143832.html