#include <iostream>
# include <iomanip>
using namespace std;
class integer
{
public:
integer()
{ int a;
cout<<"please input a integer n"<<endl;
cin>>a;
}
int factor( int &n, int*b);
void PrintNum();
~integer()
{
cout<<"well done"<<endl;
}
private:
int b[100];
int n;
};
int integer::factor ( int &n, int*b)
{
int i;
int k=0;
for(int i=1;i<=n;i++)
{
if(n%i==0)
{
b[k]=i;
k++;
}
}
return k;
}
void integer::PrintNum()
{
int size;
size=factor(n,b);
for(int i=0;i<=size;i++)
{
cout<<"the factor is:"<<setw(5)<<b[i]<<endl;
cout<<endl;
}
}
int main()
{ int n;
int b[50];
integer x;
x.factor(n,b);
x.PrintNum();
system("pause");
return 0;
}
寻找因数
最新推荐文章于 2024-03-17 20:57:54 发布