1 solutions

  • 0
    @ 2025-11-5 19:18:11

    C++ :

    #include <iostream>
    #include <string>
    using namespace std;
    
    int main(){
    	string str1,str2;
    	int i,pos,len1,len2;
    	while(true){
    		int cnt=0;
    		cin>>str1;
    		if(str1=="#") break;
    		cin>>str2;
    		len2=str2.length();
    		pos=str1.find(str2);
    		while(pos!=-1){
    			pos=str1.find(str2,pos+len2);
    			cnt++;
    		}
    		cout<<cnt<<endl;
    	} 
    }
    
    
    • 1

    Information

    ID
    19221
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By