求hack
查看原帖
求hack
551088
FincheuwYggdrasil楼主2022/8/10 15:47

题目

如能给我的程序编一个hack数据,不胜感激! 因为它会WA

#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
string str;
string s;
int k; 
bool cmop(char &a,char &b)
{
	return a > b;
}
int main()
{
	while(cin >> str)
	{
		scanf("%d",&k);
		s = str;
		sort(s.begin(),s.end(),cmop);
		for(int i = 0;i < k;i++)
		{
			int now = s[i];
			string::iterator it;
			for(it = str.begin();it != str.end();it++)
			{
				if(*it == s[i])
				{
					str.erase(it);
					break;
				}
			}
		}
		str.erase(0,str.find_first_not_of('0'));
		if(str == "")
			cout << "0" << endl;
		else
			cout << str << endl;
	}
 	return 0;
}

2022/8/10 15:47
加载中...