84分求助,我的特判没问题啊
查看原帖
84分求助,我的特判没问题啊
1096154
shr123456楼主2024/4/4 17:38
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int c,k;
	cin>>k;
	c=s.size();
	int a[255];
	for (int i=1;i<=c;i++){
		
		a[i]=int(s[i-1])-48;
		
	}
	for (int i=1;i<=k;i++){
		for (int j=1;j<=c;j++){
			if (a[j]!=-1){
				int m=j+1;	
				while (a[m]==-1)
					m+=1;
				if (a[j]>a[m]){
					a[j]=-1;
					break;
				}
				
			}
		}
	}
	int b[255]={0};
	int m=1;
	for (int i=1;i<=c;i++){
		if (a[i]!=-1){
			b[m]=a[i];
			m+=1;
		}
		
	}
	
	int ji=1;
	
	while (b[ji]==0){
		ji+=1;
	}
	if (ji==255)
		cout<<"0";
	else{
		for (int i=ji;i<=m-1;i++){
			cout<<b[i];
		}
		
		
	}
	
	
}

2024/4/4 17:38
加载中...