[华为机试题]最大连续递增子串

#include 
#include 
#include 
using namespace std;
int main()
{
    string s;
	string::size_type  length(0);
	cin>>s;
	string::size_type num = s.size();
	vector ss, ss1;
	ss.clear();
	ss1.clear();


	for (string::size_type i = 0; i != num-1; i++)
	{
		if (s.at(i+1) > s.at(i))
		{
			if (i == num - 2)
			{
				cout< s.at(i))
		{
			if (ss.empty())
			{
				ss.push_back(s.at(i));
			}
            ss.push_back(s.at(i+1));
			
         
		}
		else
		{
           if (ss.size() > length)
           {
			   length = ss.size();
			   ss1 = ss;
           } 
		   else if (ss.size() == length)
		   {
			   if (ss > ss1)
			   {
				   ss1 = ss;
			   }
		   }
		    ss.clear();
           

		}
          if (i == num -2)
          {
			  if (ss.size() > length)
			  {
				  length = ss.size();
				  ss1 = ss;
			  } 
			  else if (ss.size() == length)
			  {
				  if (ss > ss1)
				  {
					  ss1 = ss;
				  }
			  }
          }

		
		
    }
	for (vector::iterator iter =ss1.begin() ; iter != ss1.end(); iter++)
	{
		cout<<(*iter);
	}
    
	return 0;
}

你可能感兴趣的:([华为机试题]最大连续递增子串)