样例过了,提交0分,很蒙
查看原帖
样例过了,提交0分,很蒙
291604
王茗仟楼主2024/9/11 17:01

#include<bits/stdc++.h>
using namespace std;
string s;
struct{
	int first,end;
	int leng;
}maxx,minn;
int now;
int main(){
	getline(cin,s);
	int len=s.length();
	
	
	for(int i=0;i<len;i++){
		if(s[i]==' '||s[i]==','||s[i]=='.'){
			now=0;
		}
		else{
			now++;
			if(now>maxx.leng){
				maxx.leng=now;
				maxx.end=i;
				maxx.first=i-now+1;
			}
			if(now<minn.leng){
				minn.leng=now;
				minn.first=i-now+1;
				minn.end=i;
			}
		}
	}
	for(int i=maxx.first;i<=maxx.end;i++){
		putchar(s[i]);
	}
	cout<<"\n";
//	printf("\n");
	for(int i=minn.first;i<=minn.end;i++){
		putchar(s[i]);
	}
	return 0;
	
}



2024/9/11 17:01
加载中...