C++ 70分求调
查看原帖
C++ 70分求调
632830
Mark_666楼主2024/5/7 20:46

问题好像在于如果两个字符串一样就不会输出,不知道为啥

#include<bits/stdc++.h>
using namespace std;
priority_queue<string, vector<string>, greater<string> > q;
int N;
string s;
string x;
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>x;
		q.push(x);
	}
	cin>>s;
	//cout<<"\n\n\n\n\n\n\n\n\n\n";
	while(!q.empty())
	{
		string temp=q.top();
		int cnt=0;
		q.pop();
		while(temp[cnt]==s[cnt]) cnt++;
		if(cnt==s.size())
		{
			cout<<temp<<'\n';
		}
	}
	return 0;
}
2024/5/7 20:46
加载中...