帮帮忙。。。
  • 板块题目总版
  • 楼主刺客阿柒
  • 当前回复6
  • 已保存回复6
  • 发布时间2021/8/23 09:21
  • 上次更新2023/11/4 09:24:12
查看原帖
帮帮忙。。。
297572
刺客阿柒楼主2021/8/23 09:21

https://www.luogu.com.cn/problem/P1308

#include<bitsdc++.h>
using namespace std;
string s,a;
int ans,t,t1=-1;
int main(){
	cin>>s;
	int L=s.size();
	while(cin>>a){
		bool f=0;
		t1++;
		if(L!=a.size()) continue ;
		for(int i=0;i<L;i++){
			if(s[i]==a[i]) f=1;
			else if(a[i]>='a'&&a[i]<='z'){
				a[i]-=32;
				if(s[i]==a[i]) f=1;
			}
			else if(a[i]>='A'&&a[i]<='Z'){
    	        a[i]+=32;		
				if(s[i]==a[i]) f=1;		
			}
			else{
				f=0;
				break;
			}
		}
		if(f==1){
			ans++;
			if(ans==1){
				t=t1;
			}
		} 
	}
	if(ans==0){
       cout<<-1<<endl;
       return 0;
    }
	cout<<ans<<' '<<t<<endl;
	return 0;
}

有没有大佬能帮我改改代码,或者给我讲讲思路。。。 我直接输出-1得20分,写出代码得10分

2021/8/23 09:21
加载中...