首页 > 代码库 > 寻找最大的数
寻找最大的数
#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;
}