void CInput::OnDis() 
{

int i,j,ChangeColumn=0;
double N=1;
CString str,str2;
this->UpdateData(true);

int **Array,*flag,*count;
count=new int[m_ArrayNum];
Array=new int *[m_ArrayNum];
flag=new int[m_ArrayNum];
for(i=0;i<m_ArrayNum;i++)
{
N*=m_CellNum;
} for(i=0;i<m_ArrayNum;i++)
{
Array[i]=new int[m_CellNum];

}
for (i=0;i<m_ArrayNum;i++)// input data via dailog
for(j=0;j<m_CellNum;j++)
{
CInputCells InputCellDlg;
str.Format("请输入第%d组第%d个元素",i+1,j+1);
InputCellDlg.m_Item=str;
if (InputCellDlg.DoModal()==IDOK)
{
Array[i][j]=InputCellDlg.m_1d ;
}
else
return;
}this->ArrangeNum(m_CellNum,m_ArrayNum,m_ArrayNum,Array,count);//the function is here *** for(i=0;i<m_ArrayNum;i++)
{
delete Array[i];

}
delete flag;
delete count;
}

void CInput::ArrangeNum(int m, int n, int constant,int **p,int *count)//the function is here ***
{
int i,j,c; CListBox *dislistbox=(CListBox*)this->GetDlgItem(IDC_LIST);
CString str,lstr,strs;
for(count[0]=m-1;count[0]>-1;count[0]--)
{
for(count[1]=m-1;count[1]>-1;count[1]--)
{
for(count[2]=m-1;count[2]>-1;count[2]--)
{
for(count[3]=m-1;count[3]>-1;count[3]--)
{
for(count[4]=m-1;count[4]>-1;count[4]--)
{
for(count[5]=m-1;count[5]>-1;count[5]--)
{
//str.Format("%d,%d,%d,%d,%d,%d;",p[0][count[0]],p[1][count[1]],p[2][count[2]],p[3][count[3]],p[4][count[4]],p[5][count[5]]);
// lstr=lstr+str;
for(count[6]=m-1;count[6]>-1;count[6]--)
{
for(count[7]=m-1;count[7]>-1;count[7]--)
{
for(count[8]=m-1;count[8]>-1;count[8]--)
{
for(count[9]=m-1;count[9]>-1;count[9]--)
{
for(count[10]=m-1;count[10]>-1;count[10]--)
{
for(count[11]=m-1;count[11]>-1;count[11]--)
{
for(count[12]=m-1;count[12]>-1;count[12]--)
{
str.Format("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d;",p[0][count[0]],p[1][count[1]],p[2][count[2]],p[3][count[3]],p[4][count[4]],p[5][count[5]],p[6][count[6]],p[7][count[7]],p[8][count[8]],p[9][count[9]],p[10][count[10]],p[11][count[11]],p[12][count[12]]);

dislistbox->AddString(str);



}
}
}
}
}
}
}
}
}
}
}
}
}

//this->SetDlgItemText(IDC_DISWIN,lstr);
}

解决方案 »

  1.   

    最好把你调试过程中慢的地方给大家列出来。太长了,再说阅读也不方便。
    ArrangeNum函数空间复杂度为:(m-1)^12我觉得是最应该修改的!
    sorry!
      

  2.   

    太长了
    uppppppppppppppppppppppppppppppp
      

  3.   

    就那一连窜的for..for ...for... for 复杂度也太高了吧。晕呀
      

  4.   

    你的程序很乱:建议重新设计1、如果要输入100个数据,难道要弹100次对话框,输入100次数据。难道不能放到一个对话框中输入吗?2、那一堆的for....不就是阶乘吗?用递归或其它算法不是很快吗!你的脑袋好像有问题呀。  ^_^
      

  5.   

    tigerfox(风之力:=奋斗的程序员.Coding) 
    佩服,居然看完了有点晕,不看了
      

  6.   

    定义指针时要全部释放,
    最好别太用for...for ....for ...因为跟据经验,超过三个以上它的速度就很慢.所以你最好想别的方法来避开太多的循环