How fix Runtime error (access violation) at test 9 [ C code]
I don't know what problem.....
Can help me ...?
--------------------------------------------------------------------------
Code:
#include <stdio.h>
#include <math.h>
main(){
unsigned long long int inn[99999],count=0;
while(scanf("%llud",&inn[count])!=EOF){
count++;
}
printf("count:%d\n",count);
for(;count>0;){
count--;
printf("%0.4f\n",sqrt(inn[count]));
}
return 0;
}
-------------------------------------------------------------------------
Thanks for help.
Edited by author 17.05.2014 23:37
Re: How fix Runtime error (access violation) at test 9 [ C code]
Here is the solution in Java:
import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
public class Task {
public static void main(String[] args) {
DecimalFormat df=new DecimalFormat("0.0000");
int i,max;
double[] massiv=new double[130197];//130196 - runtime error at test #9
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
max=1;
while(in.hasNextDouble()){
massiv[max]=Math.sqrt(in.nextDouble());
max++;
}
max--;
for (i=max;i>=1;i--)
System.out.println(df.format(massiv[i]));
out.flush();
}
}
But I don't understand the next thing: if I change the size of array from 130197 to 130196 I'll be given "runtime error" at test #9. Why it should be 130197? How does 256 Kbytes input stream correlate with 130196 double type elements ?
Edited by author 20.06.2014 21:46
Edited by author 20.06.2014 21:48
No subject
Posted by
elf 21 Oct 2014 23:02
Edited by author 21.10.2014 23:22
Re: How fix Runtime error (access violation) at test 9 [ C code]
Posted by
Zubair 23 Feb 2015 02:56
Decrease the size of you inn Array.
set it to 99 then try.