输出很奇怪,求个位大佬帮忙看看
  • 板块P1106 删数问题
  • 楼主xuan132
  • 当前回复2
  • 已保存回复2
  • 发布时间2021/12/30 23:09
  • 上次更新2023/10/28 13:19:51
查看原帖
输出很奇怪,求个位大佬帮忙看看
582113
xuan132楼主2021/12/30 23:09
  what():  basic_string::_S_create,,网上说法感觉和我的对不上qwq
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
string s,tem,ans;int deep;
bool cmp(char x,char y)
{
	return x<y;
}
void dfs(int d,int i)
{
	if(d==deep)
	{
		int j=0;
		while(tem[j]=='0'&&tem.size()!=1)
		{
			tem.erase(tem.begin());
		}
		if(tem<ans||ans=="")
		{
			ans=tem;tem.clear();
		}
		return;
	}
	else
	{
		for(int j=i;j<s.size();j++)
		{
			tem+=s[j];
			dfs(d+1,j+1);
			string::iterator pos=tem.end();pos--;
			tem.erase(pos);
		}
	}
}
int main()
{
	int n;cin>>s>>n;deep=s.size()-n;string cy=s;
	dfs(0,0);
	cout<<ans;
	return 0;
}
2021/12/30 23:09
加载中...