回复 10楼 rjsp
谢谢啊。。。成功了。非常感谢。。。
vc大概是这么写的
头文件
#pragma once
#ifndef CNUMBER_1_H
#define CNUMBER_1_H
#include <vector>
struct DivisibleBuff
{
int nmax;
int nmin;
};
typedef std::vector<int> AryInt;
class CNumber_1
{
//构造、析构
public:
CNumber_1();
virtual ~CNumber_1();
//共有成员
public:
AryInt m_ResultAry;
//保护成员函数
protected:
//能被7或者11整除的数字
void GetCanDivisible(AryInt& ary,DivisibleBuff vbuff,int vMax,int vMin=1);
//不能被7或者11整除的数字
void GetCannotDivisible(AryInt& ary,DivisibleBuff vbuff,int vMax,int vMin=1);
//私有成员
private:
DivisibleBuff m_buff;
};
#endif
cpp文件
#include "stdafx.h"
#include "CNumber_1.h"
CNumber_1::CNumber_1()
{
}
CNumber_1::~CNumber_1()
{
}
void CNumber_1::GetCanDivisible( AryInt& ary,DivisibleBuff vbuff,int vMax,int vMin/*=1*/ )
{
for (int i=vMin;i<=vMax;i++)
{
if (!(i%vbuff.nmin) || !(i%vbuff.nmax))
{
ary.push_back(i);
}
}
}
void CNumber_1::GetCannotDivisible( AryInt& ary,DivisibleBuff vbuff,int vMax,int vMin/*=1*/ )
{
AryInt::iterator itor=ary.begin();
if (ary.empty())
{
return;
}
for (;itor!=ary.end();itor++)
{
if ((!(*itor)%vbuff.nmin) && (!(*itor)%vbuff.nmin))
{
m_ResultAry.push_back(*itor);
}
}
}