ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

text 9 Runtime error (access violation)
Posted by Emily Huo 9 Mar 2016 15:52
    #include <stdio.h>
    #include <math.h>
    #define N 100000
    int main(){
        double n;
        double line[N];
        int i = 0 ;

        while(scanf("%lf",&n) != EOF)
        {
            line[i++] = n;
        }
        while(i-- > 1)
        {
            printf("%0.4lf\n",sqrt(line[i]));
        }
        printf("%0.4lf",sqrt(line[i]));
        return 0;
    }
Re: text 9 Runtime error (access violation)
Posted by ToadMonster 9 Mar 2016 17:14
> #define N 100000

Why do you think 100,000 is enough?
Why do you place so big arrays on stack? You should better use std::vector or dynamic allocation.
Why do you have 2 equal "printf" lines? You should better change "while" condition.