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

why i get Runtime error (access violation)
Posted by Davidfeng 3 Sep 2016 08:09
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main() {
    long long a[100000] = {0};
    int i = 0;
    while (cin >> a[i]) {
        i++;
    }
    for (int j = i-1; j >= 0; j--) {
        cout << fixed << setprecision(4) << sqrt(a[j]) << endl;
    }
}
Re: why i get Runtime error (access violation)
Posted by ToadMonster 4 Sep 2016 22:14
How did you think "100,000" is enough for the input?

You shouldn't allocate big arrays on stack. You should allocate big array in heap or use vector.