#include<iostream>
#include<string.h>
using namespace 
std;
char c[100],ans[100];
int main()
{
    int 
len;
    cin>>len;
    
while(len--)
    
{
        
cin>>c;
        int 
m;
        cin>>m;
        int 
len=strlen(c);
        int 
beg=0;
        //重复确定最大,龚 
len-m次
        for(int 
i=0;i<len-m;i++)
        
{
            int 
max=-1;
            
        // 
            for(int 
j=beg;j<=m+i;j++)
            
{
                 
if((c[j]-‘0‘)>max)
                 
{
                     
max=c[j]-‘0‘;
                     
beg=j+1;
                    
// 
cout<<beg<<endl;
                 
                 
}
            
            
            
}    
            
cout<<max;
        
        
}
        cout<<endl;
  
        
    
    
    
    
    }
    
system("pause");
return 0;
}
原文地址:http://www.cnblogs.com/hansongjiang/p/3782660.html