按照字典的顺序输出字符串,并不允许重复

#include
#include
#include
using namespace std;

struct subStr
{
	string s;
	friend bool operator<(const subStr a,const subStr b)
	{
		return a.s>b.s;
	}
}newS;
priority_queue q;
//Output the strings in lexicographical order.Same substrings should be printed once.
int main()
{
	string s;
	subStr s1,s2,s3,s4,s5;
	s1.s = "a";
	s2.s = "b";
	s3.s = "a";
	s4.s = "aa";
	s5.s = "aa";
	q.push(s1);
	q.push(s2);
	q.push(s3);
	q.push(s4);
	q.push(s5);
	string beforStr = "";
	subStr temp;
	while(!q.empty())
	{
		temp = q.top();
		if(beforStr.compare(temp.s)!=0)
		{
			cout<

你可能感兴趣的:(c++)