|
|
вернуться в форумMy problem:Crash (access violation) test6 Although I tried so many times,it showed Crash (access violation) test6. Who can tell me why,thanks. My mainly code: main () { int n=0,i; double a, b[100]; for(i=0;i<100;i++) b[i]=0; while(scanf("%lf",&a)!=EOF) { b[n]=sqrt(a); n++;} for(i=n-1;i>=0;i--) printf("%.4lf\n",b[i]); } Re: My problem:Crash (access violation) test6 Array of 100 elements doesn't enough.Create a dynamic array of 8000000 elements.Just do double *b=new double[8000000]; Good luck! Edited by author 16.08.2007 19:46 Edited by author 16.08.2007 19:47 Edited by author 16.08.2007 19:47 Edited by author 16.08.2007 19:50 Re: My problem:Crash (access violation) test6 Sorry,my problem is "double *b=new double[8000000];"seems not available in C! Re: My problem:Crash (access violation) test6 if i write double[8000000]in C,it say overflow! i will mad! if this problem can't be achieved by C! Re: My problem:Crash (access violation) test6 Ok.I'm don't well on C enough.Just do: #include<stdio.h> main () { int n=0,i; double a; double *b=new double[8000000]; while(scanf("%lf",&a)!=EOF) { b[n]=sqrt(a); n++;} for(i=n-1;i>=0;i--) printf("%.4lf\n",b[i]); return 0; } and you'll get AC on C++. Edited by author 17.08.2007 18:33 Re: My problem:Crash (access violation) test6 Thank you very much! I will try it again. |
|
|