for循环语句的bug?
我写了如下程序,运行怎么没有反应,难道FOR循环有时间限制?
double GetMax(int *array, DWORD size)
{
double maxG = 0, currentG;
for(int h1=0; h1<360; h1++)
{
for(int h2=0; h2>h1; h2--)
{
currentG = 0;
for(DWORD i=0; i<size; i++)
{
if(h1 < array[i] && h2 > array[i])
{
currentG += array[i];
}
}
if(currentG > maxG)
{
maxG = currentG;
}
}
}
return maxG;
}
调用如上函数,当数组的长度为1024*1024,程序就没有响应了!
哪位大虾知道是怎么回事?
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: 关于Thinkphp二维数组循环输出问题
- 下一篇: 二级for循环的外层循环忘记退出引起的bug