user-0 提问: 用VS编程，Stack overflow，求大神帮忙，百度搜到的方法都不行

回复:
user: user-1
content: 9楼已经帮你改的编译链接没有错误了。   至于运行错误： 代码功能归根结底不是别人帮自己看或讲解或注释出来的；而是被自己静下心来花足够长的时间和精力亲自动手单步或设断点或对执行到某步获得的中间结果显示或写到日志文件中一步一步分析出来的。 提醒：再牛×的老师也无法代替学生自己领悟和上厕所！ 单步调试和设断点调试（VS IDE中编译连接通过以后，按F10或F11键单步执行，按Shift+F11退出当前函数；在某行按F9设断点后按F5执行停在该断点处。）是程序员必须掌握的技能之一。

user: user-2

user: user-3
content: 建议贴出你的源码~

user: user-4
content: 建立project

user: user-5
content: 有个网站叫stackoverflow,你去那儿问绝对有答案

user: user-0
content: 调试的时候还自动生成了一个.asm文件，如下      page    ,132         title   chkstk - C stack checking routine ;*** ;chkstk.asm - C stack checking routine ; ;       Copyright (c) Microsoft Corporation. All rights reserved. ; ;Purpose: ;       Provides support for automatic stack checking in C procedures ;       when stack checking is enabled. ; ;*******************************************************************************  .xlist         include cruntime.inc .list  ; size of a page of memory  _PAGESIZE_      equ     1000h           CODESEG  page ;*** ;_chkstk - check stack upon procedure entry ; ;Purpose: ;       Provide stack checking on procedure entry. Method is to simply probe ;       each page of memory required for the stack in descending order. This ;       causes the necessary pages of memory to be allocated via the guard ;       page scheme, if possible. In the event of failure, the OS raises the ;       _XCPT_UNABLE_TO_GROW_STACK exception. ; ;       NOTE:  Currently, the (EAX < _PAGESIZE_) code path falls through ;       to the "lastpage" label of the (EAX >= _PAGESIZE_) code path.  This ;       is small; a minor speed optimization would be to special case ;       this up top.  This would avoid the painful save/restore of ;       ecx and would shorten the code path by 4-6 instructions. ; ;Entry: ;       EAX = size of local frame ; ;Exit: ;       ESP = new stackframe, if successful ; ;Uses: ;       EAX ; ;Exceptions: ;       _XCPT_GUARD_PAGE_VIOLATION - May be raised on a page probe. NEVER TRAP ;                                    THIS!!!! It is used by the OS to grow the ;                                    stack on demand. ;       _XCPT_UNABLE_TO_GROW_STACK - The stack cannot be grown. More precisely, ;                                    the attempt by the OS memory manager to ;                                    allocate another guard page in response ;                                    to a _XCPT_GUARD_PAGE_VIOLATION has ;                                    failed. ; ;*******************************************************************************  public  _alloca_probe  _chkstk proc  _alloca_probe    =  _chkstk          push    ecx  ; Calculate new TOS.          lea     ecx, [esp] + 8 - 4      ; TOS before entering function + size for ret value         sub     ecx, eax                ; new TOS  ; Handle allocation size that results in wraparound. ; Wraparound will result in StackOverflow exception.          sbb     eax, eax                ; 0 if CF==0, ~0 if CF==1         not     eax                     ; ~0 if TOS did not wrapped around, 0 otherwise         and     ecx, eax                ; set to 0 if wraparound          mov     eax, esp                ; current TOS         and     eax, not ( _PAGESIZE_ - 1) ; Round down to current page boundary  cs10:         cmp     ecx, eax                ; Is new TOS         jb      short cs20              ; in probed page?         mov     eax, ecx                ; yes.         pop     ecx         xchg    esp, eax                ; update esp         mov     eax, dword ptr [eax]    ; get return address         mov     dword ptr [esp], eax    ; and put it at new TOS         ret  ; Find next lower page and probe cs20:         sub     eax, _PAGESIZE_         ; decrease by PAGESIZE         test    dword ptr [eax],eax     ; probe page.         jmp     short cs10  _chkstk endp          end

user: user-0
content: 调试的结果是这个样子的： “helloo.exe”: 已加载“E:\中国大学mooc\helloo\Debug\helloo.exe”，已加载符号。 “helloo.exe”: 已加载“C:\Windows\System32\ntdll.dll”，已加载符号(去除源信息)。 “helloo.exe”: 已加载“C:\Windows\System32\kernel32.dll”，已加载符号(去除源信息)。 “helloo.exe”: 已加载“C:\Windows\System32\KernelBase.dll”，已加载符号(去除源信息)。 “helloo.exe”: 已加载“C:\Windows\System32\msvcr100d.dll”，已加载符号。 程序“[9364] helloo.exe: 本机”已退出，返回值为 1 (0x1)。 真的看不懂

user: user-1
content: 在占用内存空间较大的局部数组声明的前面加static将其从堆栈数据段挪到全局数据段即可避开因局部数组大小超过默认堆栈大小1MB造成程序不能正常运行的问题。 #include<stdio.h>//定义输入／输出函数 #include<stdlib.h>//定义杂项函数及内存分配函数 #include<string.h>//字符串处理 #include<math.h>//定义数学函数  #define N 2   //2列 #define L 1000  //100行     int main(int argc, char *argv[]) {     int i,j,t,c,p,q; 	static int	zm[40][36]={0};//初水位 	static int	zn[40][36]={0};//末水位 	//int cq[p][c];//水位库容 //	double E[80][36];//余留期效益值 //	double n[i][t];//t-1到t阶段的最优出力期望   const char file_name[50] = "data.txt";       FILE *fp;     int data[N][L] = {0};   //二维数组     int index[N] = {0};   //二维数组列下标     double temp;     int v, u;     int count = 0;  //计数器，记录已读出的浮点数     if((fp=fopen(file_name, "r")) == NULL) {         //printf("请确认文件(%s)是否存在!\n", file_name);         exit(1);     }     while(1==fscanf(fp, "%lf", &temp)) {         data[count%N][(index[count%N])++] = temp;         count++;     }     for(v = 0; v < N; v++) {         for(u = 0; u < index[v]; u++) {     // printf("%d",data[v][u]) ;  //data[v][u];         }       //  printf("\n");     }     fclose(fp);  const char file[50] = "xiayou.txt";     FILE* lfp;     if((lfp=fopen(file, "r")) == NULL)     {         printf("Cannot open this filefp1\n");         exit(0);     }    int res=0;     static double  Y[2][851];     for (i = 0; i < 2; i++)     {         for (j = 0; j < 851; j++)         {             res = fscanf(lfp, "%lf", &Y[i][j]);          //    printf("%lf \n", Y[i][j]);          }      }     fclose(lfp);       int a=0,num[36]={0};         for(u = 0; u < 36; u++) { 		   // printf("%d\t",data[0][u]); 			//printf("%d\t",data[1][u]); 			//printf("\n"); 		  num[a]=data[0][u]-data[1][u]; 		  a++;          }  // for(a= 0; a < 36; a++)    //printf("%d\n",num[a]);     for(t= 0; t < 36; t++){         for(i=0;i <=num[t] ;i++){ 		zn[i][t] =data[0][t]; 		data[0][t]--; 	//	printf("%d\t",zn[i][t]); 		 			//	printf("%d\t",data[0][t]); 			//	printf("\n"); 		  } 	// printf("\n");   }  //	for(t= 0; t	< 36; t++){   //      for(i=0;i <=num[t] ;i++){ 		//	printf("%d\t",zn[i][t]); //		   } 	//	 printf("\n"); //	}       zm[0][0]=175;     for(t= 1; t < 36; t++){   //	printf("%d\t",num[t]);    //printf("%d\t",data[0][t]); //	printf("\n");         for(i=0;i <=num[t-1] ;i++){ 		zm[i][t] =zn[i][t-1]; 			//	 printf("%d\t",zn[i][t]); 			//	printf("%d\t",zm[i][t]); 		 			//	printf("%d\t",data[0][t]); 			//	printf("\n"); 		  } 	// printf("\n");   }  //  for(t= 0; t < 36; t++){ //     for(i=0;i <40 ;i++){ //      printf("%d\t",zm[i][t]); //		 }  //      printf("\n"); //	}     int cq[2][31]={0};    for(v=0;v<2;v++){     for(c=0;c<31;c++){ 		  cq[v][c]=data[v][36+c]; 			//printf("%d\t",data[p][36+c]); 			//printf("%d\t",cq[p][c]); 	   } 	 //	printf("\n");    }     static int vm[40][36]={0};    static int vn[40][36]={0}; //t阶段的初始库容和末库容    double Q[36]={5490.99,5167.74,4979.09,4479.39,4215.9,4972.32,5394.8,5715.45,5782.01,6036.54,8384.3,7269.1,10933.5,11231.05,15756.86,21060.24,16434.75,15703.82,22083.76,30670.07,29849.66,26963.16,37566.78,37049.67,31318.89,21285.04,16822.32,25209.31,17203.41,15313.36,12055.05,8785.44,8863.48,6668.28,6108.31,5249.94};       static double R[40][40][36]={0.0};//下泄流量    static double Rr[40][40][36]={0.0};     for(t= 0; t < 36; t++){         for(i=0;i <40 ;i++){ 			for(q=0;q<31;q++){ 				if(zm[i][t]	== cq[0][q]){ 				vm[i][t]=cq[1][q]; 	  //		 printf("%d\t",vm[i][t]); 				} 				continue; 			} 		 		} 	//	 printf("\n");     }      for(t= 0; t < 36; t++){         for(i=0;i <40 ;i++){ 			for(q=0;q<31;q++){ 				if(zn[i][t]	== cq[0][q]){ 				vn[i][t]=cq[1][q]; 			//	 printf("%d\t",vn[i][t]); 				} 			 				continue; 			} 		 		} 	 //	 printf("\n");     }      //	double y[40][40][36]={0.0};//弃水    //  double ***y;   double ***y = (double***)malloc(40* sizeof(double**));     for(i=0; i<40; i++)     {         y[i] = (double**)malloc(40*sizeof(double*));         for(j=0; j<40; j++)         {             y[i][j] = (double*)malloc(36*sizeof(double));         }     }      //finish creating use p[i][j][k] to access the data       //free the memory      // double *Qse=(double*)malloc(sizeof(double)*57600); 	for(t= 0; t	< 36; t++){          for(i=0;i <40 ;i++){ 			for(c=0;c<40;c++){             R[c][i][t]=vm[i][t]/10.0-vn[c][t]/10.0+Q[t];             if( 98800.0-R[c][i][t]<0.0){ 	//		 Qse[c]= R[c][i][t]-98800.0;             Rr[c][i][t]=90000.0; 			}            else  if(R[c][i][t]-5000.0>=0.0 &&98800.0-R[c][i][t]>=0.0)Rr[c][i][t]=R[c][i][t];             else continue;         //   n[c][i][t]=8.8*Rr[c][i][t]; 	//		printf("%.2f\t",R[c][i][0]); 	//		printf("%.2f\t",Qse[c] ); 			} 	//	 printf("\n"); 		}     // printf("\n");     }   	//	for(c=0;c<40;c++) 	//	{ 	//	 printf("%d\t",vm[0][0]); 	//	  printf("%d\t",vn[c][0]); 	//		printf("%.2f\n",R[c][0][0]);}   		for(t= 0; t	< 36; t++){          for(i=0;i <40 ;i++){ 			for(c=0;c<40;c++){ 				for(j=0;j<851;j++){ 			 				if((int)Rr[c][i][t]==Y[0][j])y[c][i][t]=Y[1][t]; 			 else continue;} 			}          }      }  	static double	n[40][40][36]={0.0}; 	static double	nr[40][40][36]={0.0}; 		for(t= 0; t	< 36; t++){          for(i=0;i <=num[t] ;i++){ 			for(c=0;c<=num[t];c++){ 			n[c][i][t]=8.8*Rr[c][i][t]*((zm[i][t]+zn[c][t])/2-y[c][i][t])*0.0001; 	 		//	printf("%.2f\t",nr[c][i][t] ); 		//	printf("%.2f\t",n[c][i][t] ); 		} 	//	printf("\n"); 	} //	 printf("\n");   } //  printf("%.2f\t",n[c][i][0] );  for(i=0; i<40; i++)     {         for(j=0; j<40; j++)         {             free(y[i][j]);         }     }     for(i=0; i<40; i++)     {         free(y[i]);     }     free(y);   int w,e,r,o,s,d,f,l,m,k,qw,we,er,rt,ty,yu,ui,io,op,pa; int QQ=0,W=0,E=0,RR=0,T=0,YY=0,U=0,I=0,O=0,P=0,A=0,S=0,D=0,F=0,LL=0,M=0,QW=0,WE=0,ER=0,RT=0,TY=0,YU=0,UI=0,IO=0,OP=0,PA=0; double val,valu; double max1=0; double max2=0; double max; for(pa=0;pa<=num[35];pa++){ 	for(op=0;op	<=num[34]; op++){ 		for( io=0; io<=num[33];	io++){ 			for(ui =0;ui <=num[32];	ui++){ 				for(yu =0; yu<=num[31];yu ++){ 					for( ty=0;ty <=num[30];ty ++){ 						for(rt =0;rt <=num[29];rt ++){ 							for(er =0;er <=num[28];	er++){ 								for( we=0;we <=num[27];	we++){ 									for(qw =0;qw <=num[26];qw ++){ 										for(m =0;m <=num[25]; m++){ 										val=n[m][0][25]+n[qw][m][26]+n[we][qw][27]+n[er][we][28]+n[rt][er][29]+n[ty][rt][30]+n[yu][ty][31]+n[ui][yu][32]+n[io][ui][33]+n[op][io][34]+n[pa][op][35]; 											if(val-max1>0.1){ 													max1=val; 													M=m; 													QW=qw; 													WE=we; 													ER=er; 													RT=rt; 													TY=ty; 													YU=yu; 													UI=ui; 													IO=io; 													OP=op; 													PA=pa; 											} 									 										} 									} 								} 							} 						} 					} 				} 			} 		} 	} }   for(f=0;f<=num[14];f++){   for(d=0;d<=num[13];d++){ 	for(s=0;s<=num[12];s++){ 		for(a=0;a<=num[11];a++){ 			for(p=0;p<=num[10];p++){ 				for(o=0;o<=num[9];o++){ 					for(i=0;i<=num[8];i++){ 						for(u=0;u<=num[7];u++){ 							for(k=0;k<=num[6];k++){ 								for(t=0;t<=num[5];t++){ 									for(r=0;r<=num[4];r++){ 										for(e=0;e<=num[3];e++){ 											for(w=0;w<=num[2];w++){ 												for(q=0;q<=num[1];q++){ 													for(l=0;l<=num[0];l++){ 												 													valu=n[l][0][0]+n[q][l][1]+n[w][q][2]+n[e][w][3]+n[r][e][4]+n[t][r][5]+n[k][t][6]+n[u][k][7]+n[i][u][8]+n[o][i][9]+n[p][o][10]+n[a][p][11]+n[s][a][12]+n[d][s][13]+n[f][d][14]; 													if(valu-max2>0.1) { 														max2=valu; 														LL=l; 														QQ=q; 														W=w; 														E=e; 														RR=r; 														T=t; 														YY=k; 														U=u; 														I=i; 														O=o; 														P=p; 														A=s; 														S=s; 														D=d; 														F=f; 													} 										 														} 													} 												} 											} 										} 									} 								} 							} 						} 					} 				} 			} 		} 	}  }   max=max2+n[0][F][15]+n[0][0][16]+n[0][0][17]+n[0][0][18]+n[0][0][19]+n[0][0][20]+n[0][0][21]+n[0][0][22]+n[0][0][23]+n[0][0][24]+max1; printf("%.2f\n",max); printf("%d %d %d %d %d %d %d %d %d %d\n",LL,QQ,W,E,RR,T,YY,U,I,O); printf("%d %d %d %d %d\n",P,A,S,D,F); printf("%d %d %d %d %d %d %d %d %d %d\n",M,QW,WE,ER,RT,TY,YU,UI,IO,OP); printf("%d\n",PA);  }

user: user-1
content: “给定一个小点的输入，完整单步跟踪(同时按Alt+7键查看Call Stack里面从上到下列出的对应从里层到外层的函数调用历史)一遍。”是理解递归函数工作原理的不二法门！ 递归函数关注以下几个因素 ·退出条件 ·参数有哪些 ·返回值是什么 ·局部变量有哪些 ·全局变量有哪些 ·何时输出 ·会不会导致堆栈溢出

user: user-0
content: 45400	70.92 45500	70.94 45600	70.96 45700	70.98 45800	71 45900	71.02 46000	71.04 46100	71.06 46200	71.08 46300	71.1 46400	71.12 46500	71.14 46600	71.17 46700	71.19 46800	71.21 46900	71.23 47000	71.25 47100	71.27 47200	71.29 47300	71.31 47400	71.33 47500	71.36 47600	71.38 47700	71.4 47800	71.42 47900	71.44 48000	71.46 48100	71.48 48200	71.5 48300	71.52 48400	71.54 48500	71.56 48600	71.59 48700	71.61 48800	71.63 48900	71.65 49000	71.67 49100	71.69 49200	71.71 49300	71.73 49400	71.75 49500	71.77 49600	71.79 49700	71.81 49800	71.83 49900	71.85 50000	71.87 50100	71.89 50200	71.91 50300	71.93 50400	71.95 50500	71.98 50600	72 50700	72.02 50800	72.04 50900	72.06 51000	72.08 51100	72.1 51200	72.12 51300	72.14 51400	72.16 51500	72.18 51600	72.2 51700	72.22 51800	72.24 51900	72.26 52000	72.28 52100	72.3 52200	72.32 52300	72.34 52400	72.36 52500	72.39 52600	72.41 52700	72.43 52800	72.45 52900	72.47 53000	72.49 53100	72.51 53200	72.53 53300	72.55 53400	72.57 53500	72.59 53600	72.61 53700	72.63 53800	72.65 53900	72.67 54000	72.69 54100	72.71 54200	72.73 54300	72.75 54400	72.77 54500	72.79 54600	72.81 54700	72.83 54800	72.85 54900	72.87 55000	72.89 55100	72.91 55200	72.93 55300	72.95 55400	72.97 55500	72.99 55600	73.01 55700	73.03 55800	73.05 55900	73.07 56000	73.09 56100	73.11 56200	73.13 56300	73.15 56400	73.17 56500	73.19 56600	73.21 56700	73.23 56800	73.25 56900	73.27 57000	73.29 57100	73.31 57200	73.33 57300	73.35 57400	73.37 57500	73.39 57600	73.41 57700	73.43 57800	73.45 57900	73.47 58000	73.49 58100	73.51 58200	73.53 58300	73.55 58400	73.57 58500	73.6 58600	73.62 58700	73.64 58800	73.66 58900	73.68 59000	73.7 59100	73.72 59200	73.74 59300	73.76 59400	73.78 59500	73.8 59600	73.82 59700	73.84 59800	73.86 59900	73.88 60000	73.9 60100	73.92 60200	73.94 60300	73.96 60400	73.98 60500	74 60600	74.02 60700	74.04 60800	74.06 60900	74.08 61000	74.1 61100	74.12 61200	74.14 61300	74.16 61400	74.19 61500	74.21 61600	74.23 61700	74.25 61800	74.28 61900	74.3 62000	74.32 62100	74.34 62200	74.36 62300	74.38 62400	74.4 62500	74.42 62600	74.44 62700	74.46 62800	74.48 62900	74.5 63000	74.52 63100	74.54 63200	74.56 63300	74.58 63400	74.6 63500	74.62 63600	74.65 63700	74.67 63800	74.69 63900	74.71 64000	74.73 64100	74.75 64200	74.77 64300	74.79 64400	74.82 64500	74.84 64600	74.86 64700	74.88 64800	74.9 64900	74.92 65000	74.94 65100	74.96 65200	74.98 65300	75 65400	75.02 65500	75.04 65600	75.06 65700	75.08 65800	75.1 65900	75.12 66000	75.14 66100	75.16 66200	75.18 66300	75.2 66400	75.22 66500	75.24 66600	75.26 66700	75.28 66800	75.3 66900	75.32 67000	75.34 67100	75.36 67200	75.38 67300	75.4 67400	75.42 67500	75.44 67600	75.46 67700	75.49 67800	75.51 67900	75.53 68000	75.55 68100	75.57 68200	75.59 68300	75.61 68400	75.63 68500	75.66 68600	75.68 68700	75.7 68800	75.72 68900	75.74 69000	75.76 69100	75.78 69200	75.8 69300	75.82 69400	75.84 69500	75.87 69600	75.89 69700	75.91 69800	75.93 69900	75.95 70000	75.97 70100	75.99 70200	76.01 70300	76.03 70400	76.05 70500	76.07 70600	76.09 70700	76.11 70800	76.13 70900	76.15 71000	76.17 71100	76.19 71200	76.21 71300	76.23 71400	76.25 71500	76.27 71600	76.29 71700	76.31 71800	76.33 71900	76.35 72000	76.37 72100	76.39 72200	76.41 72300	76.43 72400	76.45 72500	76.47 72600	76.49 72700	76.51 72800	76.53 72900	76.55 73000	76.57 73100	76.59 73200	76.61 73300	76.63 73400	76.65 73500	76.67 73600	76.69 73700	76.71 73800	76.73 73900	76.75 74000	76.77 74100	76.79 74200	76.81 74300	76.83 74400	76.85 74500	76.88 74600	76.9 74700	76.92 74800	76.94 74900	76.96 75000	76.98 75100	77 75200	77.02 75300	77.04 75400	77.06 75500	77.08 75600	77.1 75700	77.12 75800	77.14 75900	77.16 76000	77.18 76100	77.2 76200	77.22 76300	77.24 76400	77.26 76500	77.28 76600	77.3 76700	77.32 76800	77.34 76900	77.36 77000	77.38 77100	77.4 77200	77.42 77300	77.44 77400	77.46 77500	77.48 77600	77.5 77700	77.52 77800	77.54 77900	77.56 78000	77.58 78100	77.6 78200	77.62 78300	77.64 78400	77.66 78500	77.68 78600	77.7 78700	77.72 78800	77.74 78900	77.76 79000	77.78 79100	77.8 79200	77.82 79300	77.84 79400	77.86 79500	77.88 79600	77.9 79700	77.92 79800	77.94 79900	77.96 80000	77.98 80100	78 80200	78.02 80300	78.04 80400	78.06 80500	78.08 80600	78.1 80700	78.12 80800	78.14 80900	78.16 81000	78.18 81100	78.2 81200	78.22 81300	78.24 81400	78.26 81500	78.28 81600	78.3 81700	78.32 81800	78.34 81900	78.36 82000	78.38 82100	78.4 82200	78.42 82300	78.44 82400	78.46 82500	78.48 82600	78.5 82700	78.52 82800	78.54 82900	78.56 83000	78.58 83100	78.6 83200	78.62 83300	78.64 83400	78.66 83500	78.68 83600	78.7 83700	78.72 83800	78.74 83900	78.76 84000	78.78 84100	78.8 84200	78.82 84300	78.84 84400	78.86 84500	78.88 84600	78.9 84700	78.92 84800	78.94 84900	78.96 85000	78.98 85100	79 85200	79.02 85300	79.04 85400	79.06 85500	79.08 85600	79.1 85700	79.12 85800	79.14 85900	79.16 86000	79.18 86100	79.2 86200	79.22 86300	79.24 86400	79.26 86500	79.28 86600	79.3 86700	79.32 86800	79.34 86900	79.36 87000	79.38 87100	79.4 87200	79.42 87300	79.44 87400	79.46 87500	79.48 87600	79.5 87700	79.52 87800	79.54 87900	79.56 88000	79.58 88100	79.6 88200	79.62 88300	79.64 88400	79.66 88500	79.68 88600	79.7 88700	79.72 88800	79.74 88900	79.76 89000	79.78 89100	79.8 89200	79.82 89300	79.84 89400	79.86 89500	79.88 89600	79.9 89700	79.92 89800	79.94 89900	79.96 90000	79.98

user: user-3
content: 程序看着一个感觉比较乱： 1. for循环层数也是见过的出现最多的（我想可以通过其他算法或策略减少循环次数，循环出现最多3层为宜），循环层数多了会降低程序的运行效率。 2. 如果注释加多了，反而会起到反作用--不利于代码的阅读和理解，头文件不建议再加注释，将变量定义成见名知义，也可以省略了注释等等； 最后建议分步验证，即要验证最后的结果，就要验证前一步的正确性，如此递归。

user: user-0
content: 这个是 xiayou.txt文件的内容 5000	64.59 5100	64.6 5200	64.6 5300	64.61 5400	64.62 5500	64.62 5600	64.63 5700	64.64 5800	64.65 5900	64.65 6000	64.66 6100	64.67 6200	64.67 6300	64.68 6400	64.69 6500	64.7 6600	64.7 6700	64.71 6800	64.72 6900	64.72 7000	64.73 7100	64.74 7200	64.74 7300	64.75 7400	64.76 7500	64.76 7600	64.77 7700	64.78 7800	64.79 7900	64.79 8000	64.8 8100	64.81 8200	64.81 8300	64.82 8400	64.83 8500	64.84 8600	64.84 8700	64.85 8800	64.86 8900	64.86 9000	64.87 9100	64.88 9200	64.88 9300	64.89 9400	64.9 9500	64.9 9600	64.91 9700	64.92 9800	64.93 9900	64.93 10000	64.94 10100	64.95 10200	64.96 10300	64.97 10400	64.98 10500	64.99 10600	65 10700	65.02 10800	65.03 10900	65.04 11000	65.05 11100	65.06 11200	65.07 11300	65.08 11400	65.09 11500	65.1 11600	65.11 11700	65.12 11800	65.13 11900	65.14 12000	65.15 12100	65.16 12200	65.17 12300	65.18 12400	65.2 12500	65.21 12600	65.22 12700	65.24 12800	65.25 12900	65.26 13000	65.27 13100	65.28 13200	65.29 13300	65.3 13400	65.31 13500	65.32 13600	65.33 13700	65.34 13800	65.35 13900	65.36 14000	65.37 14100	65.381 14200	65.392 14300	65.403 14400	65.414 14500	65.42 14600	65.43 14700	65.44 14800	65.45 14900	65.47 15000	65.48 15100	65.495 15200	65.511 15300	65.52 15400	65.542 15500	65.557 15600	65.573 15700	65.58 15800	65.604 15900	65.62 16000	65.63 16100	65.64 16200	65.66 16300	65.68 16400	65.69 16500	65.7 16600	65.72 16700	65.74 16800	65.75 16900	65.76 17000	65.78 17100	65.8 17200	65.81 17300	65.83 17400	65.84 17500	65.86 17600	65.88 17700	65.89 17800	65.91 17900	65.92 18000	65.94 18100	65.96 18200	65.97 18300	65.98 18400	66 18500	66.02 18600	66.03 18700	66.04 18800	66.06 18900	66.08 19000	66.09 19100	66.1 19200	66.12 19300	66.14 19400	66.15 19500	66.16 19600	66.18 19700	66.2 19800	66.21 19900	66.22 20000	66.24 20100	66.26 20200	66.27 20300	66.29 20400	66.3 20500	66.32 20600	66.33 20700	66.35 20800	66.37 20900	66.38 21000	66.4 21100	66.42 21200	66.43 21300	66.45 21400	66.47 21500	66.48 21600	66.5 21700	66.52 21800	66.54 21900	66.55 22000	66.57 22100	66.59 22200	66.6 22300	66.62 22400	66.63 22500	66.64 22600	66.66 22700	66.67 22800	66.69 22900	66.7 23000	66.72 23100	66.74 23200	66.75 23300	66.77 23400	66.79 23500	66.8 23600	66.82 23700	66.84 23800	66.86 23900	66.87 24000	66.89 24100	66.91 24200	66.92 24300	66.94 24400	66.95 24500	66.97 24600	66.99 24700	67 24800	67.02 24900	67.03 25000	67.05 25100	67.07 25200	67.08 25300	67.1 25400	67.12 25500	67.14 25600	67.15 25700	67.17 25800	67.19 25900	67.2 26000	67.22 26100	67.24 26200	67.25 26300	67.27 26400	67.28 26500	67.3 26600	67.32 26700	67.33 26800	67.35 26900	67.36 27000	67.38 27100	67.4 27200	67.41 27300	67.43 27400	67.44 27500	67.46 27600	67.48 27700	67.49 27800	67.51 27900	67.52 28000	67.54 28100	67.56 28200	67.57 28300	67.59 28400	67.6 28500	67.62 28600	67.64 28700	67.65 28800	67.67 28900	67.68 29000	67.7 29100	67.72 29200	67.73 29300	67.75 29400	67.77 29500	67.78 29600	67.8 29700	67.82 29800	67.83 29900	67.85 30000	67.87 30100	67.89 30200	67.91 30300	67.93 30400	67.94 30500	67.96 30600	67.98 30700	68 30800	68.02 30900	68.04 31000	68.06 31100	68.08 31200	68.1 31300	68.12 31400	68.14 31500	68.16 31600	68.18 31700	68.2 31800	68.22 31900	68.24 32000	68.26 32100	68.28 32200	68.3 32300	68.32 32400	68.34 32500	68.36 32600	68.37 32700	68.39 32800	68.41 32900	68.43 33000	68.45 33100	68.47 33200	68.49 33300	68.51 33400	68.53 33500	68.54 33600	68.56 33700	68.58 33800	68.6 33900	68.62 34000	68.64 34100	68.66 34200	68.68 34300	68.7 34400	68.72 34500	68.74 34600	68.75 34700	68.77 34800	68.79 34900	68.81 35000	68.83 35100	68.85 35200	68.87 35300	68.89 35400	68.91 35500	68.93 35600	68.95 35700	68.97 35800	68.99 35900	69.01 36000	69.03 36100	69.05 36200	69.07 36300	69.09 36400	69.11 36500	69.12 36600	69.14 36700	69.16 36800	69.18 36900	69.2 37000	69.22 37100	69.24 37200	69.26 37300	69.28 37400	69.3 37500	69.32 37600	69.33 37700	69.35 37800	69.37 37900	69.39 38000	69.41 38100	69.43 38200	69.45 38300	69.47 38400	69.49 38500	69.51 38600	69.53 38700	69.55 38800	69.57 38900	69.59 39000	69.61 39100	69.63 39200	69.65 39300	69.67 39400	69.68 39500	69.7 39600	69.72 39700	69.74 39800	69.76 39900	69.78 40000	69.8 40100	69.82 40200	69.84 40300	69.86 40400	69.88 40500	69.9 40600	69.93 40700	69.95 40800	69.97 40900	69.99 41000	70.01 41100	70.03 41200	70.05 41300	70.07 41400	70.09 41500	70.12 41600	70.14 41700	70.16 41800	70.18 41900	70.2 42000	70.22 42100	70.24 42200	70.26 42300	70.28 42400	70.3 42500	70.32 42600	70.34 42700	70.36 42800	70.38 42900	70.4 43000	70.42 43100	70.44 43200	70.46 43300	70.48 43400	70.5 43500	70.52 43600	70.55 43700	70.57 43800	70.59 43900	70.61 44000	70.63 44100	70.65 44200	70.67 44300	70.69 44400	70.71 44500	70.74 44600	70.76 44700	70.78 44800	70.8 44900	70.82 45000	70.84 45100	70.86 45200	70.88 45300	70.9

user: user-0
content: 这个是data.txt里面的内容 175 155 175 155 175 155 175 155 175 155 175 155 175 145 175 145 175 145 175 145 175 145 175 145 170 145 165 145 155 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 145 155 145 165 145 175 155 175 155 175 155 175 155 175 155 175 155 175 155 175 155 175 155 145 171500  146 176446  147 181428  148 186477  149 191624  150 196900  151 202510  152 208553  153 214902  154 221427  155 228000  156 234597  157 241285  158 248076  159 254977  160 262000  161 269206  162 276641  163 284294  164 292151  165 300200  166 308463  167 316973  168 325732  169 334740  170 344000  171 353483  172 363146  173 372967  174 382925  175 393000

user: user-0
content: #include<stdio.h>//定义输入／输出函数  #include<stdlib.h>//定义杂项函数及内存分配函数  #include<string.h>//字符串处理  #include<math.h>//定义数学函数   #define N 2   //2列 #define L 1000  //100行      int main(int argc, char *argv[]) {        int i,j,t,c,p,q; 	int zm[40][36]={0};//初水位  	int zn[40][36]={0};//末水位  	//int cq[p][c];//水位库容  //	double E[80][36];//余留期效益值 //	double n[i][t];//t-1到t阶段的最优出力期望 	  const char file_name[50] = "data.txt"; 	      FILE *fp;     int data[N][L] = {0};   //二维数组     int index[N] = {0};   //二维数组列下标     double temp;       int v, u;     int count = 0;  //计数器，记录已读出的浮点数     if((fp=fopen(file_name, "rb")) == NULL) {         //printf("请确认文件(%s)是否存在!\n", file_name);         exit(1);     }     while(1==fscanf(fp, "%lf", &temp)) {         data[count%N][(index[count%N])++] = temp;         count++;     }     for(v = 0; v < N; v++) {                for(u = 0; u < index[v]; u++) {     // printf("%d",data[v][u]) ;  //data[v][u];         }       //  printf("\n");     }     fclose(fp);      const char file[50] = "xiayou.txt";      FILE* lfp;     if((lfp=fopen(file, "rb")) == NULL)     {         printf("Cannot open this filefp1\n");         exit(0);     }    int res=0;     double  Y[2][851];     for (i = 0; i < 2; i++)     {         for (j = 0; j < 851; j++)         {             res = fscanf_s(lfp, "%lf", &Y[i][j]);                     //    printf("%lf \n", Y[i][j]);                       }              }     fclose(lfp);               int a=0,num[36]={0};         for(u = 0; u < 36; u++) { 		   // printf("%d\t",data[0][u]);		     		    //printf("%d\t",data[1][u]); 			//printf("\n"); 		  num[a]=data[0][u]-data[1][u]; 		  a++; 		          }  // for(a= 0; a < 36; a++)    //printf("%d\n",num[a]);        for(t= 0; t < 36; t++){         for(i=0;i <=num[t] ;i++){   		zn[i][t] =data[0][t];   		data[0][t]--; 	//	printf("%d\t",zn[i][t]); 				 			//	printf("%d\t",data[0][t]);	 			//	printf("\n");   	      }      	// printf("\n");   }	      //	for(t= 0; t < 36; t++){    //      for(i=0;i <=num[t] ;i++){      	//  printf("%d\t",zn[i][t]); //		   } 	//	 printf("\n"); //	} 	 	      zm[0][0]=175;     for(t= 1; t < 36; t++){   //	printf("%d\t",num[t]);      //printf("%d\t",data[0][t]);	 //	printf("\n");         for(i=0;i <=num[t-1] ;i++){   		zm[i][t] =zn[i][t-1];   		    //   printf("%d\t",zn[i][t]); 			//	printf("%d\t",zm[i][t]); 				 			//	printf("%d\t",data[0][t]);	 			//	printf("\n");   	      }      	// printf("\n");   }	    //  for(t= 0; t < 36; t++){  //     for(i=0;i <40 ;i++){ //     	printf("%d\t",zm[i][t]); //		 }  //    	 printf("\n"); //  }	       int cq[2][31]={0};    for(v=0;v<2;v++){    	for(c=0;c<31;c++){    		  cq[v][c]=data[v][36+c];    			//printf("%d\t",data[p][36+c]);	 			//printf("%d\t",cq[p][c]); 	   } 	 // printf("\n");    }        	int vm[40][36]={0}; 	int vn[40][36]={0};	//t阶段的初始库容和末库容	    double Q[36]={5490.99,5167.74,4979.09,4479.39,4215.9,4972.32,5394.8,5715.45,5782.01,6036.54,8384.3,7269.1,10933.5,11231.05,15756.86,21060.24,16434.75,15703.82,22083.76,30670.07,29849.66,26963.16,37566.78,37049.67,31318.89,21285.04,16822.32,25209.31,17203.41,15313.36,12055.05,8785.44,8863.48,6668.28,6108.31,5249.94};             double R[40][40][36]={0.0};//下泄流量     double Rr[40][40][36]={0.0};     for(t= 0; t < 36; t++){         for(i=0;i <40 ;i++){         	for(q=0;q<31;q++){         		if(zm[i][t] == cq[0][q]){         		vm[i][t]=cq[1][q];	       //  		 printf("%d\t",vm[i][t]);  				}	 				continue; 			}         	   		} 	//   printf("\n");       }          for(t= 0; t < 36; t++){         for(i=0;i <40 ;i++){         	for(q=0;q<31;q++){         		if(zn[i][t] == cq[0][q]){         		vn[i][t]=cq[1][q];	         	//	 printf("%d\t",vn[i][t]); 				} 				 				continue; 			}         	   		} 	 //  printf("\n");       }        	   //	double y[40][40][36]={0.0};//弃水     //  double ***y;      double ***y = (double***)malloc(40* sizeof(double**));        for(i=0; i<40; i++)        {              y[i] = (double**)malloc(40*sizeof(double*));            for(j=0; j<40; j++)            {                y[i][j] = (double*)malloc(36*sizeof(double));            }        }          //finish creating use p[i][j][k] to access the data                  //free the memory                  // double *Qse=(double*)malloc(sizeof(double)*57600);   	for(t= 0; t < 36; t++){           for(i=0;i <40 ;i++){          	for(c=0;c<40;c++){             R[c][i][t]=vm[i][t]/10.0-vn[c][t]/10.0+Q[t];             if( 98800.0-R[c][i][t]<0.0){     //   	 Qse[c]= R[c][i][t]-98800.0;            	Rr[c][i][t]=90000.0; 			}            else  if(R[c][i][t]-5000.0>=0.0 &&98800.0-R[c][i][t]>=0.0)Rr[c][i][t]=R[c][i][t];             else continue;         //   n[c][i][t]=8.8*Rr[c][i][t]; 	//		printf("%.2f\t",R[c][i][0]); 	//		printf("%.2f\t",Qse[c] ); 			}     //   printf("\n");  	   		}     // printf("\n");     }                   //	for(c=0;c<40;c++)     //	{  	//	 printf("%d\t",vm[0][0]); 	//	  printf("%d\t",vn[c][0]);     //		printf("%.2f\n",R[c][0][0]);}               	for(t= 0; t < 36; t++){           for(i=0;i <40 ;i++){          	for(c=0;c<40;c++){          		for(j=0;j<851;j++){ 				         		if((int)Rr[c][i][t]==Y[0][j])y[c][i][t]=Y[1][t];          	 else continue;}          	}          }      }        	double n[40][40][36]={0.0};   	double nr[40][40][36]={0.0};     	for(t= 0; t < 36; t++){           for(i=0;i <=num[t] ;i++){          	for(c=0;c<=num[t];c++){          	n[c][i][t]=8.8*Rr[c][i][t]*((zm[i][t]+zn[c][t])/2-y[c][i][t])*0.0001; 		 		//	printf("%.2f\t",nr[c][i][t] );	 		//	printf("%.2f\t",n[c][i][t] );	 		}  	//	printf("\n");  	} //	 printf("\n");    } //  printf("%.2f\t",n[c][i][0] );    for(i=0; i<40; i++)      {         for(j=0; j<40; j++)          {                free(y[i][j]);            }        }            for(i=0; i<40; i++)        {                free(y[i]);        }        free(y);         int w,e,r,o,s,d,f,l,m,k,qw,we,er,rt,ty,yu,ui,io,op,pa; int QQ=0,W=0,E=0,RR=0,T=0,YY=0,U=0,I=0,O=0,P=0,A=0,S=0,D=0,F=0,LL=0,M=0,QW=0,WE=0,ER=0,RT=0,TY=0,YU=0,UI=0,IO=0,OP=0,PA=0; double val,valu; double max1=0; double max2=0; double max; for(pa=0;pa<=num[35];pa++){ 	for(op=0;op <=num[34]; op++){ 		for( io=0; io<=num[33]; io++){ 			for(ui =0;ui <=num[32]; ui++){ 				for(yu =0; yu<=num[31];yu ++){ 					for( ty=0;ty <=num[30];ty ++){ 						for(rt =0;rt <=num[29];rt ++){ 							for(er =0;er <=num[28]; er++){ 								for( we=0;we <=num[27]; we++){ 									for(qw =0;qw <=num[26];qw ++){ 										for(m =0;m <=num[25]; m++){ 										val=n[m][0][25]+n[qw][m][26]+n[we][qw][27]+n[er][we][28]+n[rt][er][29]+n[ty][rt][30]+n[yu][ty][31]+n[ui][yu][32]+n[io][ui][33]+n[op][io][34]+n[pa][op][35]; 											if(val-max1>0.1){ 													max1=val; 									             	M=m; 									             	QW=qw; 									             	WE=we; 									             	ER=er; 									             	RT=rt; 									             	TY=ty; 									             	YU=yu; 									             	UI=ui; 									             	IO=io; 									               	OP=op; 									             	PA=pa; 											} 										 										} 									} 								} 							} 						} 					} 				} 			} 		} 	} }   for(f=0;f<=num[14];f++){   for(d=0;d<=num[13];d++){ 	for(s=0;s<=num[12];s++){ 		for(a=0;a<=num[11];a++){ 			for(p=0;p<=num[10];p++){ 				for(o=0;o<=num[9];o++){ 					for(i=0;i<=num[8];i++){ 						for(u=0;u<=num[7];u++){ 							for(k=0;k<=num[6];k++){ 								for(t=0;t<=num[5];t++){ 									for(r=0;r<=num[4];r++){ 										for(e=0;e<=num[3];e++){ 											for(w=0;w<=num[2];w++){ 												for(q=0;q<=num[1];q++){ 													for(l=0;l<=num[0];l++){ 												        													valu=n[l][0][0]+n[q][l][1]+n[w][q][2]+n[e][w][3]+n[r][e][4]+n[t][r][5]+n[k][t][6]+n[u][k][7]+n[i][u][8]+n[o][i][9]+n[p][o][10]+n[a][p][11]+n[s][a][12]+n[d][s][13]+n[f][d][14]; 												    if(valu-max2>0.1) { 												    	max2=valu; 													    LL=l; 												      	QQ=q; 													    W=w; 												     	E=e; 												        RR=r; 												     	T=t; 												    	YY=k; 												    	U=u; 												    	I=i; 												     	O=o; 												     	P=p; 												     	A=s; 												     	S=s; 												     	D=d; 												     	F=f;		 													}    												 														} 													} 												} 											} 										} 									} 								} 							} 						} 					} 				} 			} 		} 	}  }   max=max2+n[0][F][15]+n[0][0][16]+n[0][0][17]+n[0][0][18]+n[0][0][19]+n[0][0][20]+n[0][0][21]+n[0][0][22]+n[0][0][23]+n[0][0][24]+max1; printf("%.2f\n",max); printf("%d %d %d %d %d %d %d %d %d %d\n",LL,QQ,W,E,RR,T,YY,U,I,O); printf("%d %d %d %d %d\n",P,A,S,D,F); printf("%d %d %d %d %d %d %d %d %d %d\n",M,QW,WE,ER,RT,TY,YU,UI,IO,OP); printf("%d\n",PA);  }   程序之前运行到259行都是正确的，可以输出n[][][]的值，但是加上后面两个循环以后就不能输出了