#include<iostream>
using namespace std;
class NUM
{
private:
int n, count;
int* p;
public:
NUM(int);
int isdiff(int);
int issort(int);
void process();
void print();
~NUM();
};
NUM::NUM(int num)
{
n = num;
count = 0;
p = new int[num];
}
int NUM::isdiff(int num)
{
int x[6] = { 0 };//因为n<400,所以最大的数num也只有3位,只需要存储3个元素//这里错了,x<n(n<400),但是num=x*x,远大于3位,因此越界了。越界时,提示stack around the variable was corrupted
int i = 0;
while (num)
{
x[i] = num % 10;
num = num / 10;
i++;
}
int a, b;
for (a = 0; a <= i - 1; a++)
{
for (b = 0; b <= i - 1; b++)
{
if (x[a] == x[b] && a != b)
{
return 1;//如果有重复
}
}
}
return 0;//满足
}//一种办法,还有一种可以直接用 num/1%10,num/10%10...来检验有没有相等的
int NUM::issort(int num)
{
int x[6] = { 0 };//因为n<400,所以最大的数num也只有3位,只需