20分求助
查看原帖
20分求助
466724
sunjun123楼主2022/10/4 08:51
#include<iostream>
#include<cstring> 
using namespace std;
int main(){
	char a[11]={};
	cin>>a;
	int lena=strlen(a);
	string b[10000]={};
	int i=1;
	for(int j=0;j<lena;j++){
		if(a[j]<='z' and a[j]>='a'){
			a[j]-=32;
		}
	}
	i=1;
	int s=0;
	int c;
	bool cb=false;
	bool t=true;
	while(cin>>b[i]){
		t=true;
		int lenb=b[i].length();
		for(int j=0;j<lenb;j++){
			if(b[i][j]<='z' and b[i][j]>='a'){
				b[i][j]-=32;
			}
		}
		if(lenb==lena){
			for(int j=0;j<lena;j++){
				if(a[j]!=b[i][j]){
					t=false;
					break;
				}
			}
			if(t and !cb){
				s++;
				c=i-1;
				cb=true;
			}else if(t and cb){
				s++;
			}
		}
		i++;
	}
	if(s){
		cout<<s<<" "<<c;
	}else{
		cout<<-1;
	}
	return 0;
}

只能过样例和-1的点,不知道错哪了,求助

2022/10/4 08:51
加载中...