0分,求助大佬们
查看原帖
0分,求助大佬们
958584
Shiyuming2011楼主2023/7/6 08:49

以下是代码,求各位大佬帮忙指出以下错误,谢谢

#include<bits/stdc++.h>
using namespace std;
string a[10010];
int main(){
	int sum=1;
	while(cin>>a[sum]){
		sum++;
	}
	sum--;
	int biggest=0,smallest=1e6+10;
	string biggestrec,smallestrec;
	for(int i=1;i<=sum;++i){
		if(a[i].length()>biggest){
			biggest=a[i].length();
			biggestrec=a[i];
		}
		if(a[i].length()<smallest){
			smallestrec=a[i];
			smallest=a[i].length();
		}
	}
	cout<<biggestrec<<endl<<smallestrec;
	return 0;
} 
2023/7/6 08:49
加载中...