急急急!!!在线等待,如何让这段程序运行更快?

wbel 2003-10-17 06:18:06
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);
}
...全文
27 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
xushinhwa2003 2003-10-18
  • 打赏
  • 举报
回复
定义指针时要全部释放,
最好别太用for...for ....for ...因为跟据经验,超过三个以上它的速度就很慢.所以你最好想别的方法来避开太多的循环
fanfyj 2003-10-18
  • 打赏
  • 举报
回复
up
javazb 2003-10-18
  • 打赏
  • 举报
回复
wasai,受不了!
dzqsuper 2003-10-18
  • 打赏
  • 举报
回复
好强哦
这么长的一段你也敢拿出来
静虚极 2003-10-18
  • 打赏
  • 举报
回复
tigerfox(风之力:=奋斗的程序员.Coding)
佩服,居然看完了

有点晕,不看了
linfeng1216 2003-10-18
  • 打赏
  • 举报
回复
up!
tigerfox 2003-10-17
  • 打赏
  • 举报
回复
你的程序很乱:建议重新设计

1、如果要输入100个数据,难道要弹100次对话框,输入100次数据。难道不能放到一个对话框中输入吗?

2、那一堆的for....不就是阶乘吗?用递归或其它算法不是很快吗!

你的脑袋好像有问题呀。 ^_^

tigerfox 2003-10-17
  • 打赏
  • 举报
回复
就那一连窜的for..for ...for... for 复杂度也太高了吧。

晕呀
yintongshun 2003-10-17
  • 打赏
  • 举报
回复
看着下边那些括号怎么象星星。
Paris_Luo 2003-10-17
  • 打赏
  • 举报
回复
太长了
uppppppppppppppppppppppppppppppp
apcad 2003-10-17
  • 打赏
  • 举报
回复
最好把你调试过程中慢的地方给大家列出来。太长了,再说阅读也不方便。
ArrangeNum函数空间复杂度为:(m-1)^12我觉得是最应该修改的!
sorry!
wuxfBrave 2003-10-17
  • 打赏
  • 举报
回复
up
zhucde 2003-10-17
  • 打赏
  • 举报
回复
不是吧,这么长的程序贴出来?
看得让人头晕,
明天再来

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧