#include<iostream>
#include<string>
using namespace std;
int mVal,nVal;
int *pOut;
void calFun(int m,int n){
if(m<1 ||n<1||(n==1&&m!=1))
return;
if(m==n){
pOut[n] =1;
for(int i=1;i<=nVal;i++)
{
if(pOut[i])
cout<<i<<" ";
}
cout<<endl;
pOut[n]=0;
}
calFun(m,n-1);
pOut[n]=1;
calFun(m-n,n-1);
pOut[n]=0;
}
int main(){
cout<<"m:";
cin>>mVal;
cout<<"n:";
cin>>nVal;
if(mVal<nVal) nVal =mVal;//±È½ÏnºÍmÄǸö´ó
pOut = new int [nVal+1];
memset(pOut,0,(nVal+1)*sizeof(int));
calFun(mVal,nVal);
delete []pOut;
return 0;
}
posted on 2008-07-31 10:53
fly 阅读(352)
评论(0) 编辑 收藏 所属分类:
C/C++学习