#include
#include
using namespace std;
unsigned long getRadix(int n)
{
unsigned long lRadix = 1;
while(--n)
{
lRadix = lRadix * 10;
}
return lRadix;
}
bool VerifyNumber(unsigned long m, int n)
{
unsigned int nLength = 0;
char buffer[15];
_itoa_s(m, buffer, 15, 10);
nLength = (unsigned int)strlen(buffer);
if (nLength != n)
return false;
bool bRs = true;
while(nLength>1)
{
if (nLength == 2)
{
if (m%100/10 <= m%10)
{
bRs = false;
break;
}
}
else
{
int i, j;
i = m/getRadix(nLength);
j = (m-m/getRadix(nLength)*getRadix(nLength))/getRadix(nLength-1);
if (i <= j)
{
bRs = false;
break;
}
}
m -= m/getRadix(nLength)*getRadix(nLength);
nLength--;
}
return bRs;
}
void fun(int m, int n)
{
unsigned long lMax = 0;
lMax = m;
int i = n;
while(i>1)
{
lMax += m * getRadix(i) ;
i--;
}
cout << "The Max number is : " << lMax <
while(lMax)
{
if(VerifyNumber(lMax, n))
cout << lMax << " ";
lMax--;
}
}
int main(void)
{
fun(9,4);
cin.get();
return 0;
}
--------------------next---------------------
阅读(1172) | 评论(0) | 转发(0) |