首页 > 其他 > 详细

最大值bug 调试

时间:2014-03-10 11:53:01      阅读:226      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
小组成员:贾川,李驭龙







#include "stdafx.h" #include"stdio.h" int Largest(int list[], int length) { int i; int j=1; int max=list[0]; for(i = 0; i <= (length - 1); i ++ ) { if((list[i]<-2147483648) && (list[i]>2147483647)) { return 0; } else { if(list[i]>=max) { max=list[i]; } } } return max; } void main() { int A[1]={-2147483649}; printf("-2147483649"); printf("\n%d\n",Largest(A,1)); int B[1]={2147483649}; printf("2147483649"); printf("\n%d\n",Largest(B,1)); int C[3]={NULL}; printf("NULL"); printf("\n%d\n",Largest(C,0)); int D[3]={1,2,3}; printf("1,2,3"); printf("\n%d\n",Largest(D,3)); int E[3]={0}; printf("0"); printf("\n%d\n",Largest(E,3)); int F[3]={7,-8,9}; printf("7,-8,9"); printf("\n%d\n",Largest(F,3)); int G[3]={-6,-6,-7}; printf("-6,-6,-7"); printf("\n%d\n",Largest(G,3)); }
bubuko.com,布布扣

1·需要注意数组内部值的范围。

2·注意初始化max,不能直接赋值为0,而是要将数组中第一个数赋给max,即

max=list[0]。

最大值bug 调试,布布扣,bubuko.com

最大值bug 调试

原文:http://www.cnblogs.com/ID-q-han/p/3590738.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!