HDU 2087: 剪花布条

HDU 2087: 剪花布条

abcde a3 aaaaaa aa #
0 3
#include <iostream>
#include <string>  
using namespace std;  
int main(){  
    int j,a;
    string str,temp;  
    while(cin>>str>>temp&&str[0]!='#')  {  
        a=j=0;
        for(int i=0;i<str.size();i++){  
            if(str[i]==temp[j]){  
                j++;  
                if(j==temp.length()){  
                    a++;  
                    j=0;  
                }  
            }  
            else{  
                i-=j;  
                j=0;  
            }  
        }  
        cout<<a<<endl;  
    }  
    return 0;  
}
View Code
原文地址:https://www.cnblogs.com/Rhythm-/p/9348900.html