2 条题解

  • 3
    @ 2023-3-29 20:09:22
    #include<iostream>
    using namespace std;
    int cnt,wz=-1,i;
    char x;
    string n,s;
    int main(){
    	cin>>n;
    	for(int i=0;i<=n.size()-1;i++){
    		n[i]=toupper(n[i]);
    	}
    	while(cin.get(x)){
    		if('a'<=x&&x<='z')x=toupper(x);
    		if('A'<=x&&x<='Z')s+=x;//连接字母
    		else{
    			if(n==s){//检查是否一样
    				cnt++;
    				if(wz==-1)wz=i-n.size()-1;//总字符串长度-现字符串长度
    			}
    			s="";//连接下一个单词
    		}
    		i++;//总长度
    	}
    	if(cnt)cout<<cnt<<" ";
    	cout<<wz;
    	return 0;
    }
    
    • @ 2025-10-19 14:39:11

      要加string

  • -3
    @ 2023-4-18 16:44:29
    using namespace std;
    int cnt,wz=-1,i;
    char x;
    string n,s;
    int main(){
    	cin>>n;
    	for(int i=0;i<=n.size()-1;i++){
    		n[i]=toupper(n[i]);
    	}
    	while(cin.get(x)){
    		if('a'<=x&&x<='z')x=toupper(x);
    		if('A'<=x&&x<='Z')s+=x;
    		else{
    			if(n==s){
    				cnt++;
    				if(wz==-1)wz=i-n.size()-1;
    			}
    			s="";
    		}
    		i++;
    	}
    	if(cnt)cout<<cnt<<" ";
    	cout<<wz;
    	return 0;
    }
    
    • @ 2023-5-9 13:51:40

      @抄题解这么明显?除了头文件和注释全抄了

  • 1

信息

ID
715
时间
1000ms
内存
256MiB
难度
7
标签
递交数
329
已通过
83
上传者